summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-06 19:47:38 +0000
committerPaul Phillips <paulp@improving.org>2011-01-06 19:47:38 +0000
commit5d022058c4fb2f448eee35d6df7f508c24d2a0be (patch)
treed5559585ad49acf14b979439258be07ccaf7fbe8 /src/compiler/scala/tools/ant/templates/tool-unix.tmpl
parent04f59ea9e8238cc9561a3281dfaa22808dc0a1b8 (diff)
downloadscala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.tar.gz
scala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.tar.bz2
scala-5d022058c4fb2f448eee35d6df7f508c24d2a0be.zip
The shutdown hook installed by jline has made l...
The shutdown hook installed by jline has made life difficult for sbt for a while. This changes jline not to install it, and alters the scala startup script to trap exit and re-enable echo on recognizably unix platforms. In addition it no longer installs a shutdown hook to flush the repl history to disk, instead flushing after every line. Any bash reviewers out there? Unless someone raises a hand, no review.
Diffstat (limited to 'src/compiler/scala/tools/ant/templates/tool-unix.tmpl')
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 4227e19a50..452324304e 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -8,6 +8,26 @@
# PARTICULAR PURPOSE.
##############################################################################
+function onExit() {
+ if [[ -n "$scaladebug" ]]; then
+ echo "scala script runner trapped exit, running handler."
+ fi
+
+ local exit_status=${1:-$?}
+
+ # reenable echo
+ case "$TERM" in
+ rxvt* | xterm*)
+ stty icanon echo
+ ;;
+ esac
+
+ exit $exit_status
+}
+
+# install exit handler
+trap onExit EXIT
+
cygwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
@@ -50,9 +70,6 @@ if [ -z "$TOOL_CLASSPATH" ] ; then
done
fi
-EXEC=exec
-CYGWIN_TERM_PRE=
-CYGWIN_TERM_POST=
CYGWIN_JLINE_TERMINAL=
if $cygwin; then
if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
@@ -64,15 +81,10 @@ if $cygwin; then
TOOL_CLASSPATH=`cygpath --path --$format "$TOOL_CLASSPATH"`
case "$TERM" in
rxvt* | xterm*)
- EXEC=
- CYGWIN_TERM_PRE="stty -icanon min 1 -echo"
- CYGWIN_TERM_POST="stty icanon echo"
+ stty -icanon min 1 -echo
CYGWIN_JLINE_TERMINAL="-Djline.terminal=jline.UnixTerminal"
- trap "$CYGWIN_TERM_POST" SIGINT
;;
esac
-else
- trap "stty echo" SIGINT
fi
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="@javaflags@"
@@ -117,9 +129,7 @@ if [ -z "$JAVACMD" -a -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
fi
-eval $CYGWIN_TERM_PRE
-
-$EXEC "${JAVACMD:=java}" \
+"${JAVACMD:=java}" \
$JAVA_OPTS \
"${java_args[@@]}" \
$CPSWITCH \
@@ -128,5 +138,3 @@ $EXEC "${JAVACMD:=java}" \
-Denv.emacs="$EMACS" \
$CYGWIN_JLINE_TERMINAL \
@properties@ @class@ @toolflags@ "$@@"
-
-eval $CYGWIN_TERM_POST