Skip to content

Commit 2b59dc7

Browse files
committed
fix: need to capture all scripting args when script arg is detected
1 parent 1b7b21d commit 2b59dc7

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

dist/bin/scala

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,34 +118,35 @@ while [[ $# -gt 0 ]]; do
118118
shift ;;
119119

120120
*)
121-
if [ "${execute_mode-}" == 'script' ]; then
122-
addScript "$1"
123-
else
124-
# script if extension .scala or .sc, or if has scala hashbang line
125-
126-
# no -f test, issue meaningful error message (file not found)
127-
if [[ "$1" == *.scala || "$1" == *.sc ]]; then
128-
setExecuteMode 'script' # execute_script=true
129-
130-
# -f test needed before we examine the hashbang line
131-
elif [[ (-f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
132-
setExecuteMode 'script' # execute_script=true
133-
fi
121+
# script if extension .scala or .sc, or if has scala hashbang line
122+
# no -f test, issue meaningful error message (file not found)
123+
if [[ "$1" == *.scala || "$1" == *.sc ]]; then
124+
setExecuteMode 'script' # execute_script=true
125+
126+
# -f test needed before we examine the hashbang line
127+
elif [[ (-f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
128+
setExecuteMode 'script' # execute_script=true
129+
fi
134130

135-
if [ "${execute_mode-}" == 'script' ]; then
136-
target_script="$1"
137-
if [ ! -f $target_script ]; then
138-
# likely a typo or missing script file, quit early
139-
echo "not found: $target_script" 1>&2
140-
scala_exit_status=2
141-
onExit
142-
fi
143-
else
144-
# all unrecognized args appearing prior to a script name
145-
addResidual "$1"
131+
if [ "${execute_mode-}" == 'script' ]; then
132+
target_script="$1"
133+
shift
134+
if [ ! -f $target_script ]; then
135+
# likely a typo or missing script file, quit early
136+
echo "not found: $target_script" 1>&2
137+
scala_exit_status=2
138+
onExit
146139
fi
140+
# all are script args
141+
while [[ $# -gt 0 ]]; do
142+
addScript "${1}"
143+
shift
144+
done
145+
else
146+
# all unrecognized args appearing prior to a script name
147+
addResidual "$1"
148+
shift
147149
fi
148-
shift
149150
;;
150151

151152
esac

dist/bin/scalac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ case "$1" in
4242
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
4343
-repl) PROG_NAME="$ReplMain" && shift ;;
4444
-script) PROG_NAME="$ScriptingMain" && target_script="$2" && shift && shift
45-
while [[ $# -gt 0 ]]; do addScripting "$1" && shift ; done ;;
45+
while [[ $# -gt 0 ]]; do addScript "$1" && shift ; done ;;
4646
-compile) PROG_NAME="$CompilerMain" && shift ;;
4747
-decompile) PROG_NAME="$DecompilerMain" && shift ;;
4848
-print-tasty) PROG_NAME="$DecompilerMain" && addScala "-print-tasty" && shift ;;
@@ -64,7 +64,7 @@ compilerJavaClasspathArgs
6464

6565
if [ "$PROG_NAME" == "$ScriptingMain" ]; then
6666
setScriptName="-Dscript.path=$target_script"
67-
scripting_string="-script $target_script ${scripting_args[@]}"
67+
scripting_string="-script $target_script ${script_args[@]}"
6868
fi
6969

7070
[ -n "$script_trace" ] && set -x

0 commit comments

Comments
 (0)