Skip to content

Commit

Permalink
fix: We now properly notify Jbang we're running in PowerShell
Browse files Browse the repository at this point in the history
`JBANG_USES_POWERSHELL=true` was set too late for Jbang to pick it up.
It also fixes the fact that jbang on Windows wasn't properly delegating
to the downloaded version when using "zero install".

Fixes quarkusio#401
  • Loading branch information
quintesse authored and maxandersen committed Oct 8, 2020
1 parent e2ce5fb commit bf629db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/scripts/jbang.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ if exist "%~dp0jbang.jar" (
if !ERRORLEVEL! NEQ 0 ( echo Error installing JBang 1>&2 & exit /b %ERRORLEVEL% )
ren "%TDIR%\jars\jbang.tmp" "jbang"
)
call "%TDIR%\jars\jbang\jbang\bin\jbang.cmd" %*
exit /b %ERRORLEVEL%
)

rem Find/get a JDK
Expand Down
4 changes: 3 additions & 1 deletion src/main/scripts/jbang.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ if (Test-Path "$PSScriptRoot\jbang.jar") {
}
Rename-Item -Path "$TDIR\jars\jbang.tmp" -NewName "jbang" >$null 2>&1
}
. "$TDIR\jars\jbang\jbang\bin\jbang.ps1" $args
break
}

# Find/get a JDK
Expand Down Expand Up @@ -129,14 +131,14 @@ if ($JAVA_EXEC -eq "") {
}
}

$env:JBANG_USES_POWERSHELL="true"
$output = & $JAVA_EXEC $env:JBANG_JAVA_OPTIONS -classpath "$jarPath" dev.jbang.Main $args
$err=$LASTEXITCODE

$erroractionpreference=$old_erroractionpreference
$global:progresspreference=$old_progresspreference

if ($err -eq 255) {
$env:JBANG_USES_POWERSHELL="true"
Invoke-Expression "& $output"
} else {
Write-Output $output
Expand Down

0 comments on commit bf629db

Please sign in to comment.