Skip to content

Commit 693ffc5

Browse files
committed
more robust script detection in dist/bin/scala
1 parent 6c0a15e commit 693ffc5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dist/bin/scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ while [[ $# -gt 0 ]]; do
7878
shift
7979
;;
8080
-save|-savecompiled)
81-
save_compiled=1
81+
save_compiled=true
8282
addDotcOptions "${1}"
8383
shift
8484
;;
@@ -93,10 +93,11 @@ while [[ $# -gt 0 ]]; do
9393
*)
9494
if [ $execute_script == false ]; then
9595
# is a script if extension .scala or .sc or if has scala hash bang
96-
if [[ "$1" == *.scala || "$1" == *.sc || -f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'` ]]; then
96+
if [[ -e "$1" && ("$1" == *.scala || "$1" == *.sc || -f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
9797
execute_script=true
9898
[ -n "$SCALA_OPTS" ] && java_options+=($SCALA_OPTS)
9999
target_script="$1"
100+
if [ ! -f $target_script
100101
else
101102
residual_args+=("$1")
102103
fi
@@ -113,9 +114,9 @@ if [ $execute_script == true ]; then
113114
if [ "$CLASS_PATH" ]; then
114115
cp_arg="-classpath \"$CLASS_PATH\""
115116
fi
117+
setScriptName="-Dscript.path=$target_script"
116118
target_jar="${target_script%.*}.jar"
117119
jar_found=false
118-
setScriptName="-Dscript.path=$target_script"
119120
[[ $save_compiled == true && -f "$target_jar" ]] && jar_found=true
120121
if [[ $jar_found == true && "$target_jar" -nt "$target_script" ]]; then
121122
java $setScriptName -jar "$target_jar" "${script_args[@]}"

0 commit comments

Comments
 (0)