Skip to content

Commit 8ed3ac8

Browse files
maxandersenCopilot
andauthored
docs: document bootstrap@jbangdev (jbangdev#2231)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1ee2d0e commit 8ed3ac8

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

docs/modules/ROOT/pages/first-script.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ jbang hello.java your-args
9595
3.3.0 and newer versions things just works.
9696
====
9797

98+
== Self-bootstrapping Scripts
99+
100+
It is possible to enhance the shebang to make self-bootstrapping JBang scripts.
101+
102+
There is a bootstrap script available in the JBang repository:
103+
104+
[source,bash]
105+
----
106+
jbang bootstrap@jbangdev hello.java
107+
----
108+
109+
This will add or update the shebang header to something like:
110+
111+
[source,bash]
112+
----
113+
///usr/bin/env bash -c 'command -v jbang >/dev/null 2>&1 || { echo "Bootstrapping JBang..." >&2; curl -Ls https://sh.jbang.dev | bash -s - app setup --quiet ; export PATH="$HOME/.jbang/bin:$PATH"; }; exec jbang "$0" "$@"' "$0" "$@"; exit $?
114+
----
115+
116+
Which is a mouthful, but basically translate to:
117+
118+
1. Check if jbang is in PATH
119+
2. If not, install JBang using the default install script and set PATH temporarily to include the newly installed jbang
120+
3. Execute freshly installed jbang with the same arguments as the script
121+
98122
== Java Version Management
99123

100124
JBang automatically handles Java versions for you:

misc/bootstrap_jbang.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)