aboutsummaryrefslogtreecommitdiff
path: root/build/sbt
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@gmail.com>2015-02-09 11:45:12 -0800
committerMichael Armbrust <michael@databricks.com>2015-02-09 11:45:21 -0800
commitfa67877c2323122d4ee10ea9c4175ef0473cedcc (patch)
treeec44cfdcd722e9c64a1ab9cae076a1c02d4f06d3 /build/sbt
parentc88d4ab1ddf025335c8b0ebd99de90cdacf09fed (diff)
downloadspark-fa67877c2323122d4ee10ea9c4175ef0473cedcc.tar.gz
spark-fa67877c2323122d4ee10ea9c4175ef0473cedcc.tar.bz2
spark-fa67877c2323122d4ee10ea9c4175ef0473cedcc.zip
[SPARK-5664][BUILD] Restore stty settings when exiting from SBT's spark-shell
For launching spark-shell from SBT. Author: Liang-Chi Hsieh <viirya@gmail.com> Closes #4451 from viirya/restore_stty and squashes the following commits: fdfc480 [Liang-Chi Hsieh] Restore stty settings when exit (for launching spark-shell from SBT). (cherry picked from commit dae216147f2247fd722fb0909da74fe71cf2fa8b) Signed-off-by: Michael Armbrust <michael@databricks.com>
Diffstat (limited to 'build/sbt')
-rwxr-xr-xbuild/sbt28
1 files changed, 28 insertions, 0 deletions
diff --git a/build/sbt b/build/sbt
index 28ebb64f71..cc3203d79b 100755
--- a/build/sbt
+++ b/build/sbt
@@ -125,4 +125,32 @@ loadConfigFile() {
[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@"
[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@"
+exit_status=127
+saved_stty=""
+
+restoreSttySettings() {
+ stty $saved_stty
+ saved_stty=""
+}
+
+onExit() {
+ if [[ "$saved_stty" != "" ]]; then
+ restoreSttySettings
+ fi
+ exit $exit_status
+}
+
+saveSttySettings() {
+ saved_stty=$(stty -g 2>/dev/null)
+ if [[ ! $? ]]; then
+ saved_stty=""
+ fi
+}
+
+saveSttySettings
+trap onExit INT
+
run "$@"
+
+exit_status=$?
+onExit