Skip to content

Commit 490b91e

Browse files
committed
avoid duplicate call to dist/bin/common on script startup
1 parent 4af1386 commit 490b91e

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

dist/bin/common

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ case "`uname`" in
5454
esac
5555

5656
unset CYGPATHCMD
57-
if [[ $cygwin || $mingw || $msys ]]; then
57+
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
5858
# ConEmu terminal is incompatible with jna-5.*.jar
59-
[[ ($CONEMUANSI || $ConEmuANSI) ]] && conemu=true
59+
[[ (${CONEMUANSI-} || ${ConEmuANSI-}) ]] && conemu=true
6060
# cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
6161
CYGPATHCMD=`which cygpath 2>/dev/null`
6262
case "$TERM" in
@@ -111,14 +111,14 @@ CLASSPATH_SUFFIX=""
111111
PSEP=":"
112112

113113
# translate paths to Windows-mixed format before running java
114-
if [ -n "$CYGPATHCMD" ]; then
115-
[ -n "$PROG_HOME" ] &&
114+
if [ -n "${CYGPATHCMD-}" ]; then
115+
[ -n "${PROG_HOME-}" ] &&
116116
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
117117
[ -n "$JAVA_HOME" ] &&
118118
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
119119
CLASSPATH_SUFFIX=";"
120120
PSEP=";"
121-
elif [[ $mingw || $msys ]]; then
121+
elif [[ ${mingw-} || ${msys-} ]]; then
122122
# For Mingw / Msys, convert paths from UNIX format before anything is touched
123123
[ -n "$PROG_HOME" ] &&
124124
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
@@ -134,9 +134,9 @@ fi
134134

135135
find_lib () {
136136
local lib=$(find $PROG_HOME/lib/ -name "$1")
137-
if [ -n "$CYGPATHCMD" ]; then
137+
if [ -n "${CYGPATHCMD-}" ]; then
138138
$CYGPATHCMD -am $lib
139-
elif [[ $mingw || $msys ]]; then
139+
elif [[ ${mingw-} || ${msys-} ]]; then
140140
echo $lib | sed 's|/|\\\\|g'
141141
else
142142
echo $lib
@@ -155,8 +155,13 @@ SBT_INTF=$(find_lib "*compiler-interface*")
155155
JLINE_READER=$(find_lib "*jline-reader-3*")
156156
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
157157
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
158-
[[ $conemu ]] || JNA=$(find_lib "*jna-5*")
158+
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")
159159

160160
# debug
161161

162162
DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
163+
164+
export saved_stty PROG_HOME DEBUG_STR PSEP SCALA_LIB DOTTY_LIB SCALA_ASM SBT_INTF DOTTY_INTF DOTTY_COMP TASTY_CORE
165+
export DOTTY_STAGING DOTTY_TASTY_INSPECTOR JLINE_READER JLINE_TERMINAL JLINE_TERMINAL_JNA JNA JAVACMD SCALA_OPTS
166+
export cygwin mingw msys darwin conemu CLASSPATH_SUFFIX
167+
export -f onExit restoreSttySettings find_lib

dist/bin/scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Try to autodetect real location of the script
4-
5-
if [ -z "$PROG_HOME" ] ; then
4+
if [ -z "${PROG_HOME-}" ] ; then
65
## resolve links - $0 may be a link to PROG_HOME
76
PRG="$0"
87

@@ -107,9 +106,15 @@ while [[ $# -gt 0 ]]; do
107106
*)
108107
if [ $execute_script == false ]; then
109108
# is a script if extension .scala or .sc or if has scala hash bang
110-
if [[ -e "$1" && ("$1" == *.scala || "$1" == *.sc || -f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
109+
if [[ "$1" == *.scala || "$1" == *.sc || (-f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
111110
execute_script=true
112111
target_script="$1"
112+
if [ ! -f $target_script ]; then
113+
# likely a typo or missing script file, quit early
114+
echo "not found: $target_script" 1>&2
115+
scala_exit_status=2
116+
onExit
117+
fi
113118
else
114119
residual_args+=("$1")
115120
fi

dist/bin/scalac

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
if [ -z "$PROG_HOME" ] ; then
3+
if [ -z "${PROG_HOME-}" ] ; then
44
## resolve links - $0 may be a link to PROG_HOME
55
PRG="$0"
66

@@ -25,7 +25,8 @@ if [ -z "$PROG_HOME" ] ; then
2525
cd "$saveddir"
2626
fi
2727

28-
source "$PROG_HOME/bin/common"
28+
# only source common if necessary
29+
[ -z "${DEBUG_STR-}" -a -z "${PSEP-}" ] && source "$PROG_HOME/bin/common"
2930

3031
default_java_opts="-Xmx768m -Xms768m"
3132
withCompiler=true

0 commit comments

Comments
 (0)