44# * Credits: This script is based on the script generated by sbt-pack.
55# *--------------------------------------------------------------------------*/
66
7+ # save terminal settings
8+ saved_stty=$( stty -g 2> /dev/null)
9+ # clear on error so we don't later try to restore them
10+ if [[ ! $? ]]; then
11+ saved_stty=" "
12+ fi
13+
14+ # restore stty settings (echo in particular)
15+ function restoreSttySettings() {
16+ stty $saved_stty
17+ saved_stty=" "
18+ }
19+
20+ scala_exit_status=127
21+ function onExit() {
22+ [[ " $saved_stty " != " " ]] && restoreSttySettings
23+ exit $scala_exit_status
24+ }
25+
26+ # to reenable echo if we are interrupted before completing.
27+ trap onExit INT TERM
28+
729cygwin=false
830mingw=false
31+ msys=false
932darwin=false
1033case " ` uname` " in
1134 CYGWIN* ) cygwin=true
1235 ;;
1336 MINGW* ) mingw=true
1437 ;;
38+ MSYS* ) msys=true
39+ ;;
1540 Darwin* ) darwin=true
1641 if [ -z " $JAVA_VERSION " ] ; then
1742 JAVA_VERSION=" CurrentJDK"
@@ -25,6 +50,18 @@ case "`uname`" in
2550 ;;
2651esac
2752
53+ unset CYGPATHCMD
54+ if [[ ($cygwin || $mingw || $msys ) ]]; then
55+ # cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
56+ CYGPATHCMD=` which cygpath 2> /dev/null`
57+ case " $TERM " in
58+ rxvt* | xterm* | cygwin* )
59+ stty -icanon min 1 -echo
60+ SCALA_OPTS=" $SCALA_OPTS -Djline.terminal=unix"
61+ ;;
62+ esac
63+ fi
64+
2865# Resolve JAVA_HOME from javac command path
2966if [ -z " $JAVA_HOME " ]; then
3067 javaExecutable=" ` which javac` "
@@ -41,9 +78,8 @@ if [ -z "$JAVA_HOME" ]; then
4178 fi
4279fi
4380
44-
45- if [ -z " $JAVACMD " ] ; then
46- if [ -n " $JAVA_HOME " ] ; then
81+ if [ -z " ${JAVACMD-} " ] ; then
82+ if [ -n " ${JAVA_HOME-} " ] ; then
4783 if [ -x " $JAVA_HOME /jre/sh/java" ] ; then
4884 # IBM's JDK on AIX uses strange locations for the executables
4985 JAVACMD=" $JAVA_HOME /jre/sh/java"
@@ -69,18 +105,16 @@ CLASSPATH_SUFFIX=""
69105# Path separator used in EXTRA_CLASSPATH
70106PSEP=" :"
71107
72- # For Cygwin, switch paths to Windows-mixed format before running java
73- if $cygwin ; then
108+ # translate paths to Windows-mixed format before running java
109+ if [ -n " $CYGPATHCMD " ] ; then
74110 [ -n " $PROG_HOME " ] &&
75- PROG_HOME=` cygpath -am " $PROG_HOME " `
111+ PROG_HOME=` " $CYGPATHCMD " -am " $PROG_HOME " `
76112 [ -n " $JAVA_HOME " ] &&
77- JAVA_HOME=` cygpath -am " $JAVA_HOME " `
113+ JAVA_HOME=` " $CYGPATHCMD " -am " $JAVA_HOME " `
78114 CLASSPATH_SUFFIX=" ;"
79115 PSEP=" ;"
80- fi
81-
82- # For Migwn, ensure paths are in UNIX format before anything is touched
83- if $mingw ; then
116+ elif ($mingw || $msys ); then
117+ # For Mingw / Msys, convert paths from UNIX format before anything is touched
84118 [ -n " $PROG_HOME " ] &&
85119 PROG_HOME=" ` (cd " $PROG_HOME " ; pwd -W | sed ' s|/|\\\\|g' )` "
86120 [ -n " $JAVA_HOME " ] &&
95129
96130find_lib () {
97131 local lib=$( find $PROG_HOME /lib/ -name " $1 " )
98- if $cygwin ; then
99- cygpath -am $lib
100- elif $mingw ; then
132+ if [ -n " $CYGPATHCMD " ] ; then
133+ $CYGPATHCMD -am $lib
134+ elif ( $mingw || $msys ) ; then
101135 echo $lib | sed ' s|/|\\\\|g'
102136 else
103137 echo $lib
@@ -116,7 +150,7 @@ SBT_INTF=$(find_lib "*compiler-interface*")
116150JLINE_READER=$( find_lib " *jline-reader-3*" )
117151JLINE_TERMINAL=$( find_lib " *jline-terminal-3*" )
118152JLINE_TERMINAL_JNA=$( find_lib " *jline-terminal-jna-3*" )
119- JNA=$( find_lib " *jna-5*" )
153+ [[ ( $mingw || $msys ) ]] || JNA=$( find_lib " *jna-5*" )
120154
121155# debug
122156DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
0 commit comments