Skip to content

Commit 6361c82

Browse files
committed
case-lib: hijack.sh use trap to hijack exit command
use 'trap' command hijack exit command instead of function 'exit' which perpare for 'set -e' Signed-off-by: Wu, BinX <binx.wu@intel.com>
1 parent b4fe945 commit 6361c82

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

case-lib/hijack.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
SUDO_CMD=$(command -v sudo)
44

5+
trap 'func_hijack_exit' EXIT
56
# Overwrite other functions' exit to perform environment cleanup
6-
function exit()
7+
function func_hijack_exit()
78
{
89
local exit_status=${1:-0}
910

@@ -77,6 +78,7 @@ function exit()
7778
;;
7879
esac
7980

81+
trap '' EXIT
8082
builtin exit $exit_status
8183
}
8284

0 commit comments

Comments
 (0)