summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-27 18:36:47 +0000
committerPaul Phillips <paulp@improving.org>2011-04-27 18:36:47 +0000
commit6a5a5ed2179938c729bc4d4ed03b839eed0e86fb (patch)
tree7bcf610a42672810fe15d1d91d41a9dbc940deb2 /src/compiler/scala/tools/ant/templates/tool-unix.tmpl
parentb18773a98847c61842850d1c63b0db649fa6558d (diff)
downloadscala-6a5a5ed2179938c729bc4d4ed03b839eed0e86fb.tar.gz
scala-6a5a5ed2179938c729bc4d4ed03b839eed0e86fb.tar.bz2
scala-6a5a5ed2179938c729bc4d4ed03b839eed0e86fb.zip
Trying out a different strategy for restoring t...
Trying out a different strategy for restoring terminal settings so we don't have a list of hardcoded terminal types. Now it saves the terminal settings on script start and restores those on exit. Closes #4170, review by rytz.
Diffstat (limited to 'src/compiler/scala/tools/ant/templates/tool-unix.tmpl')
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index 1976535333..a3dc58263b 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -9,29 +9,39 @@
##############################################################################
# Not sure what the right default is here: trying nonzero.
-SCALA_EXIT_STATUS=127
-REENABLE_ECHO=true
-
-function reenableEcho() {
- REENABLE_ECHO=false
- # reenable echo
- case "$TERM" in
- rxvt* | xterm* | screen*)
- stty icanon echo
- ;;
- esac
+scala_exit_status=127
+saved_stty=""
+
+# restore stty settings (echo in particular)
+function restoreSttySettings() {
+ if [[ -n $SCALA_RUNNER_DEBUG ]]; then
+ echo "restoring stty: $saved_stty"
+ fi
+
+ stty $saved_stty
+ saved_stty=""
}
function onExit() {
- if $REENABLE_ECHO; then
- reenableEcho
- exit $SCALA_EXIT_STATUS
+ if [[ "$saved_stty" != "" ]]; then
+ restoreSttySettings
+ exit $scala_exit_status
fi
}
# to reenable echo if we are interrupted before completing.
trap onExit INT
+# save terminal settings
+saved_stty=$(stty -g 2>/dev/null)
+# clear on error so we don't later try to restore them
+if [[ ! $? ]]; then
+ saved_stty=""
+fi
+if [[ -n $SCALA_RUNNER_DEBUG ]]; then
+ echo "saved stty: $saved_stty"
+fi
+
cygwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
@@ -152,5 +162,5 @@ fi
# record the exit status lest it be overwritten:
# then reenable echo and propagate the code.
-SCALA_EXIT_STATUS=$?
+scala_exit_status=$?
onExit