Skip to content

Commit

Permalink
fix: Jbang won't print extra newline when no output was generated (qu…
Browse files Browse the repository at this point in the history
  • Loading branch information
quintesse authored Oct 13, 2020
1 parent f4fa8c5 commit 765d8cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions itests/output.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: output

Scenario: test for clean output
When command('jbang alias remove dummy-alias-name')
* match exit == 0
* match out == ""
* match err == ""
4 changes: 3 additions & 1 deletion src/main/scripts/jbang
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ output=$(CLICOLOR_FORCE=1 ${JAVA_EXEC} ${JBANG_JAVA_OPTIONS} -classpath ${jarPat
err=$?
if [ $err -eq 255 ]; then
eval "exec $output"
else
elif [ ! -z "$output" ]; then
echo "$output"
exit $err
else
exit $err
fi
1 change: 1 addition & 0 deletions src/main/scripts/jbang.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ if "!JAVA_EXEC!"=="" (
if not exist "%TDIR%" ( mkdir "%TDIR%" )
set tmpfile=%TDIR%\%RANDOM%.jbang.tmp
rem execute jbang and pipe to temporary random file
set JBANG_USES_POWERSHELL=
set "CMD=!JAVA_EXEC!"
SETLOCAL DISABLEDELAYEDEXPANSION
%CMD% > "%tmpfile%" %JBANG_JAVA_OPTIONS% -classpath "%jarPath%" dev.jbang.Main %*
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 @@ -145,7 +145,9 @@ $global:progresspreference=$old_progresspreference

if ($err -eq 255) {
Invoke-Expression "& $output"
} else {
} elseif ($output -ne "") {
Write-Output $output
break
} else {
break
}

0 comments on commit 765d8cc

Please sign in to comment.