Skip to content

Commit 302b186

Browse files
Merge pull request #11539 from philwalk/scalac-common-patch
fix for #11536 and other terminal and shell environment issues
2 parents ebdd3cc + 9403273 commit 302b186

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

compiler/src/dotty/tools/scripting/Main.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object Main:
5252
val javaClasspath = sys.props("java.class.path")
5353
val runtimeClasspath = s"${classpath}$pathsep$javaClasspath"
5454

55-
val jarTargetDir: Path = Option(scriptFile.toPath.getParent) match {
55+
val jarTargetDir: Path = Option(scriptFile.toPath.toAbsolutePath.getParent) match {
5656
case None => sys.error(s"no parent directory for script file [$scriptFile]")
5757
case Some(parent) => parent
5858
}

dist/bin/common

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ function onExit() {
2424
}
2525

2626
# to reenable echo if we are interrupted before completing.
27-
trap onExit INT TERM
27+
trap onExit INT TERM EXIT
2828

29-
cygwin=false
30-
mingw=false
31-
msys=false
32-
darwin=false
29+
unset cygwin mingw msys darwin conemu
3330
case "`uname`" in
3431
CYGWIN*) cygwin=true
3532
;;
@@ -51,7 +48,9 @@ case "`uname`" in
5148
esac
5249

5350
unset CYGPATHCMD
54-
if [[ ($cygwin||$mingw||$msys) ]]; then
51+
if [[ $cygwin || $mingw || $msys ]]; then
52+
# ConEmu terminal is incompatible with jna-5.*.jar
53+
[[ ($CONEMUANSI || $ConEmuANSI) ]] && conemu=true
5554
# cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
5655
CYGPATHCMD=`which cygpath 2>/dev/null`
5756
case "$TERM" in
@@ -113,7 +112,7 @@ if [ -n "$CYGPATHCMD" ]; then
113112
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
114113
CLASSPATH_SUFFIX=";"
115114
PSEP=";"
116-
elif ($mingw || $msys); then
115+
elif [[ $mingw || $msys ]]; then
117116
# For Mingw / Msys, convert paths from UNIX format before anything is touched
118117
[ -n "$PROG_HOME" ] &&
119118
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
@@ -131,7 +130,7 @@ find_lib () {
131130
local lib=$(find $PROG_HOME/lib/ -name "$1")
132131
if [ -n "$CYGPATHCMD" ]; then
133132
$CYGPATHCMD -am $lib
134-
elif ($mingw || $msys); then
133+
elif [[ $mingw || $msys ]]; then
135134
echo $lib | sed 's|/|\\\\|g'
136135
else
137136
echo $lib
@@ -150,7 +149,8 @@ SBT_INTF=$(find_lib "*compiler-interface*")
150149
JLINE_READER=$(find_lib "*jline-reader-3*")
151150
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
152151
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
153-
[[ ($mingw||$msys) ]] || JNA=$(find_lib "*jna-5*")
152+
[[ $conemu ]] || JNA=$(find_lib "*jna-5*")
154153

155154
# debug
155+
156156
DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

dist/bin/scalac

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ if [ "$PROG_NAME" == "$ScriptingMain" ]; then
120120
scripting_string="-script $target_script ${scripting_args[@]}"
121121
fi
122122

123-
eval exec "\"$JAVACMD\"" \
123+
eval "\"$JAVACMD\"" \
124124
${JAVA_OPTS:-$default_java_opts} \
125125
"${DEBUG-}" \
126126
"${java_args[@]}" \
@@ -130,4 +130,5 @@ eval exec "\"$JAVACMD\"" \
130130
"${scala_args[@]}" \
131131
"${residual_args[@]}" \
132132
"${scripting_string-}"
133-
exit $?
133+
scala_exit_status=$?
134+
onExit

dist/bin/scaladoc

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ done
125125

126126
classpathArgs
127127

128-
eval exec "\"$JAVACMD\"" \
128+
eval "\"$JAVACMD\"" \
129129
${JAVA_OPTS:-$default_java_opts} \
130130
"$DEBUG" \
131131
"${java_args[@]}" \
@@ -134,4 +134,5 @@ eval exec "\"$JAVACMD\"" \
134134
"${scala_args[@]}" \
135135
"${residual_args[@]}" \
136136
"$scripting_string"
137-
exit $?
137+
scala_exit_status=$?
138+
onExit

0 commit comments

Comments
 (0)