Skip to content

avoid duplicate call to dist/bin/common on script startup #11698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions dist/bin/common
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ case "`uname`" in
esac

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

# translate paths to Windows-mixed format before running java
if [ -n "$CYGPATHCMD" ]; then
[ -n "$PROG_HOME" ] &&
if [ -n "${CYGPATHCMD-}" ]; then
[ -n "${PROG_HOME-}" ] &&
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
CLASSPATH_SUFFIX=";"
PSEP=";"
elif [[ $mingw || $msys ]]; then
elif [[ ${mingw-} || ${msys-} ]]; then
# For Mingw / Msys, convert paths from UNIX format before anything is touched
[ -n "$PROG_HOME" ] &&
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
Expand All @@ -135,7 +135,7 @@ fi
find_lib () {
local lib=$(find $PROG_HOME/lib/ -name "$1")
if [ -n "$CYGPATHCMD" ]; then
$CYGPATHCMD -am $lib
"$CYGPATHCMD" -am $lib
elif [[ $mingw || $msys ]]; then
echo $lib | sed 's|/|\\\\|g'
else
Expand All @@ -155,8 +155,13 @@ SBT_INTF=$(find_lib "*compiler-interface*")
JLINE_READER=$(find_lib "*jline-reader-3*")
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
[[ $conemu ]] || JNA=$(find_lib "*jna-5*")
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")

# debug

DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

export saved_stty DEBUG_STR PSEP SCALA_LIB DOTTY_LIB SCALA_ASM SBT_INTF DOTTY_INTF DOTTY_COMP TASTY_CORE
export DOTTY_STAGING DOTTY_TASTY_INSPECTOR JLINE_READER JLINE_TERMINAL JLINE_TERMINAL_JNA JNA JAVACMD SCALA_OPTS
export cygwin mingw msys darwin conemu CLASSPATH_SUFFIX
export -f onExit find_lib
11 changes: 8 additions & 3 deletions dist/bin/scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env bash

# Try to autodetect real location of the script

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

Expand Down Expand Up @@ -107,9 +106,15 @@ while [[ $# -gt 0 ]]; do
*)
if [ $execute_script == false ]; then
# is a script if extension .scala or .sc or if has scala hash bang
if [[ -e "$1" && ("$1" == *.scala || "$1" == *.sc || -f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
if [[ "$1" == *.scala || "$1" == *.sc || (-f "$1" && `head -n 1 -- "$1" | grep '#!.*scala'`) ]]; then
execute_script=true
target_script="$1"
if [ ! -f $target_script ]; then
# likely a typo or missing script file, quit early
echo "not found: $target_script" 1>&2
scala_exit_status=2
onExit
fi
else
residual_args+=("$1")
fi
Expand Down
5 changes: 3 additions & 2 deletions dist/bin/scalac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

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

Expand All @@ -25,7 +25,8 @@ if [ -z "$PROG_HOME" ] ; then
cd "$saveddir"
fi

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

default_java_opts="-Xmx768m -Xms768m"
withCompiler=true
Expand Down