From 3ea197e5df0de834151dccfa0c7f70651741cac9 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 2 Mar 2017 01:25:51 +0200 Subject: t-rex-64: catch exit with trap to restore tty settings Change-Id: Id336aa95ceff5e958e9bce329c85eb7201772712 Signed-off-by: Yaroslav Brustinov --- scripts/t-rex-64 | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'scripts/t-rex-64') diff --git a/scripts/t-rex-64 b/scripts/t-rex-64 index c92d48b0..de83c4c8 100755 --- a/scripts/t-rex-64 +++ b/scripts/t-rex-64 @@ -33,11 +33,13 @@ cd $(dirname $0) export LD_LIBRARY_PATH=$PWD +function restore_tty { + stty $saveterm +} + if [ -t 0 ] && [ -t 1 ]; then - export is_tty=true saveterm="$(stty -g)" -else - export is_tty=false + trap restore_tty EXIT fi # if we have a new core run optimized trex @@ -56,12 +58,5 @@ else RESULT=$? fi -if $is_tty; then - stty $saveterm -fi - -if [ $RESULT -ne 0 ]; then - exit $RESULT -fi - +exit $RESULT -- cgit 1.2.3-korg