From 3d723a8614512ffdcd12903d87089037a0d802de Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 25 Feb 2021 13:25:04 -0700 Subject: [PATCH 1/5] fix for various combinations of terminal and shell environment; fix for #11536 --- dist/bin/common | 19 +++++++++---------- dist/bin/scalac | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dist/bin/common b/dist/bin/common index d6da956207da..761df21ca698 100755 --- a/dist/bin/common +++ b/dist/bin/common @@ -24,12 +24,9 @@ function onExit() { } # to reenable echo if we are interrupted before completing. -trap onExit INT TERM +trap onExit INT TERM EXIT -cygwin=false -mingw=false -msys=false -darwin=false +unset cygwin mingw msys darwin conemu case "`uname`" in CYGWIN*) cygwin=true ;; @@ -51,8 +48,9 @@ case "`uname`" in esac unset CYGPATHCMD -if [[ ($cygwin||$mingw||$msys) ]]; then +if [[ $cygwin || $mingw || $msys ]]; then # cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc. + [[ ($CONEMUANSI || $ConEmuANSI) ]] && conemu=true CYGPATHCMD=`which cygpath 2>/dev/null` case "$TERM" in rxvt* | xterm* | cygwin*) @@ -113,7 +111,7 @@ if [ -n "$CYGPATHCMD" ]; then 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')`" @@ -131,7 +129,7 @@ find_lib () { local lib=$(find $PROG_HOME/lib/ -name "$1") if [ -n "$CYGPATHCMD" ]; then $CYGPATHCMD -am $lib - elif ($mingw || $msys); then + elif [[ $mingw || $msys ]]; then echo $lib | sed 's|/|\\\\|g' else echo $lib @@ -150,7 +148,8 @@ 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*") -[[ ($mingw||$msys) ]] || JNA=$(find_lib "*jna-5*") - +# ConEmu must not define +[[ $conemu ]] || JNA=$(find_lib "*jna-5*") # debug + DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 diff --git a/dist/bin/scalac b/dist/bin/scalac index f81c20853bd2..b509189eae6e 100755 --- a/dist/bin/scalac +++ b/dist/bin/scalac @@ -120,7 +120,7 @@ if [ "$PROG_NAME" == "$ScriptingMain" ]; then scripting_string="-script $target_script ${scripting_args[@]}" fi -eval exec "\"$JAVACMD\"" \ +eval "\"$JAVACMD\"" \ ${JAVA_OPTS:-$default_java_opts} \ "${DEBUG-}" \ "${java_args[@]}" \ From a7eb2e825bcb97ec681015c7f2fcb30119072895 Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 25 Feb 2021 14:57:18 -0700 Subject: [PATCH 2/5] updated dist/bin/common comments --- dist/bin/common | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/bin/common b/dist/bin/common index 761df21ca698..da5ae4aeff66 100755 --- a/dist/bin/common +++ b/dist/bin/common @@ -49,8 +49,9 @@ esac unset CYGPATHCMD if [[ $cygwin || $mingw || $msys ]]; then - # cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc. + # ConEmu terminal is incompatible with jna-5.*.jar [[ ($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 rxvt* | xterm* | cygwin*) @@ -148,8 +149,8 @@ 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 must not define [[ $conemu ]] || JNA=$(find_lib "*jna-5*") + # debug DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 From 767abe151398ac3d5fd8e8b605d93b605b0d54cb Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 25 Feb 2021 16:23:28 -0700 Subject: [PATCH 3/5] capture scalac return value for onExit --- dist/bin/scalac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/bin/scalac b/dist/bin/scalac index b509189eae6e..3479da81fedd 100755 --- a/dist/bin/scalac +++ b/dist/bin/scalac @@ -130,4 +130,5 @@ eval "\"$JAVACMD\"" \ "${scala_args[@]}" \ "${residual_args[@]}" \ "${scripting_string-}" -exit $? +scala_exit_status=$? +exit $scala_exit_status From 07e9106007f6fe323caa830528c69372ac42b988 Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 25 Feb 2021 23:20:05 -0700 Subject: [PATCH 4/5] convert relative path to absolute before getParent --- compiler/src/dotty/tools/scripting/Main.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/scripting/Main.scala b/compiler/src/dotty/tools/scripting/Main.scala index cf1e76994441..ded809b9f675 100644 --- a/compiler/src/dotty/tools/scripting/Main.scala +++ b/compiler/src/dotty/tools/scripting/Main.scala @@ -52,7 +52,7 @@ object Main: val javaClasspath = sys.props("java.class.path") val runtimeClasspath = s"${classpath}$pathsep$javaClasspath" - val jarTargetDir: Path = Option(scriptFile.toPath.getParent) match { + val jarTargetDir: Path = Option(scriptFile.toPath.toAbsolutePath.getParent) match { case None => sys.error(s"no parent directory for script file [$scriptFile]") case Some(parent) => parent } From 9403273dd2a9640cf08400ccacc815f29ab7e77f Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 27 Feb 2021 12:49:08 -0700 Subject: [PATCH 5/5] unified scala_exit_status and onExit for dist/bin scripts --- dist/bin/scalac | 2 +- dist/bin/scaladoc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dist/bin/scalac b/dist/bin/scalac index 3479da81fedd..74bfc4a603fe 100755 --- a/dist/bin/scalac +++ b/dist/bin/scalac @@ -131,4 +131,4 @@ eval "\"$JAVACMD\"" \ "${residual_args[@]}" \ "${scripting_string-}" scala_exit_status=$? -exit $scala_exit_status +onExit diff --git a/dist/bin/scaladoc b/dist/bin/scaladoc index b536dbf99e4e..304da8f5045d 100755 --- a/dist/bin/scaladoc +++ b/dist/bin/scaladoc @@ -125,7 +125,7 @@ done classpathArgs -eval exec "\"$JAVACMD\"" \ +eval "\"$JAVACMD\"" \ ${JAVA_OPTS:-$default_java_opts} \ "$DEBUG" \ "${java_args[@]}" \ @@ -134,4 +134,5 @@ eval exec "\"$JAVACMD\"" \ "${scala_args[@]}" \ "${residual_args[@]}" \ "$scripting_string" -exit $? +scala_exit_status=$? +onExit