diff options
author | Liang-Chi Hsieh <viirya@gmail.com> | 2015-02-09 11:45:12 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-02-09 11:45:12 -0800 |
commit | dae216147f2247fd722fb0909da74fe71cf2fa8b (patch) | |
tree | 102721437e79ce78e1d7f42554afb492f6f5ac90 /build | |
parent | afb131637d96e1e5e07eb8abf24e32e7f3b2304d (diff) | |
download | spark-dae216147f2247fd722fb0909da74fe71cf2fa8b.tar.gz spark-dae216147f2247fd722fb0909da74fe71cf2fa8b.tar.bz2 spark-dae216147f2247fd722fb0909da74fe71cf2fa8b.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).
Diffstat (limited to 'build')
-rwxr-xr-x | build/sbt | 28 | ||||
-rwxr-xr-x | build/sbt-launch-lib.bash | 2 |
2 files changed, 29 insertions, 1 deletions
@@ -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 diff --git a/build/sbt-launch-lib.bash b/build/sbt-launch-lib.bash index 5e0c640fa5..504be48b35 100755 --- a/build/sbt-launch-lib.bash +++ b/build/sbt-launch-lib.bash @@ -81,7 +81,7 @@ execRunner () { echo "" } - exec "$@" + "$@" } addJava () { |