diff --git a/src/main/java/dev/jbang/cli/Build.java b/src/main/java/dev/jbang/cli/Build.java index 8ac5c78c1f440..c4974c7415b76 100644 --- a/src/main/java/dev/jbang/cli/Build.java +++ b/src/main/java/dev/jbang/cli/Build.java @@ -19,6 +19,6 @@ public Integer doCall() throws IOException { build(script); } - return EXIT_EXECUTE; + return EXIT_OK; } } diff --git a/src/main/scripts/jbang b/src/main/scripts/jbang index 67bfcbbc82a29..6d628d0440bfa 100755 --- a/src/main/scripts/jbang +++ b/src/main/scripts/jbang @@ -41,6 +41,27 @@ download() { abs_jbang_path=$(resolve_symlink $(absolute_path $0)) +case "$(uname -s)" in + Linux*) + os=linux;; + Darwin*) + os=mac;; + CYGWIN*|MINGW*) + os=windows;; + *) echo "Unsupported Operating System: $(uname -s)" 1>&2; exit 1;; +esac + +case "$(uname -m)" in + i?86) + arch=x32;; + x86_64|amd64) + arch=x64;; + aarch64) + arch=aarch64;; + *) + echo "Unsupported Architecture: $(uname -m)" 1>&2; exit 1;; +esac + ## when mingw/git bash or cygwin fall out to just running the bat file. if [[ $os == windows ]]; then $(dirname $abs_jbang_path)/jbang.cmd $* @@ -72,27 +93,6 @@ else eval "exec $JBDIR/bin/jbang $*" fi -case "$(uname -s)" in - Linux*) - os=linux;; - Darwin*) - os=mac;; - CYGWIN*|MINGW*) - os=windows;; - *) echo "Unsupported Operating System: $(uname -s)" 1>&2; exit 1;; -esac - -case "$(uname -m)" in - i?86) - arch=x32;; - x86_64|amd64) - arch=x64;; - aarch64) - arch=aarch64;; - *) - echo "Unsupported Architecture: $(uname -m)" 1>&2; exit 1;; -esac - # Find/get a JDK unset JAVA_EXEC if [[ -n "$JAVA_HOME" ]]; then diff --git a/src/main/scripts/jbang.cmd b/src/main/scripts/jbang.cmd index 40ae3f7a6802b..3bb58d87be1a1 100644 --- a/src/main/scripts/jbang.cmd +++ b/src/main/scripts/jbang.cmd @@ -83,7 +83,8 @@ if "!JAVA_EXEC!"=="" ( ) ) -set tmpfile=%TDIR%\%RANDOM%.tmp +if not exist "%TDIR%" ( mkdir "%TDIR%" ) +set tmpfile=%TDIR%\%RANDOM%.jbang.tmp rem execute jbang and pipe to temporary random file set "CMD=!JAVA_EXEC!" SETLOCAL DISABLEDELAYEDEXPANSION