mirror of
https://github.com/sheumann/hush.git
synced 2025-01-03 00:31:16 +00:00
add test cases for trap
... but disabled for now until trap support is committed
This commit is contained in:
parent
038fe44713
commit
fd303b11ef
4
shell/hush_test/hush-trap/catch.right
Normal file
4
shell/hush_test/hush-trap/catch.right
Normal file
@ -0,0 +1,4 @@
|
||||
sending USR2
|
||||
caught
|
||||
sending USR2
|
||||
sending USR2
|
20
shell/hush_test/hush-trap/catch.tests
Normal file
20
shell/hush_test/hush-trap/catch.tests
Normal file
@ -0,0 +1,20 @@
|
||||
# avoid ugly warnings about signals not being caught
|
||||
trap ":" USR1 USR2
|
||||
|
||||
hush -c '
|
||||
trap "echo caught" USR2
|
||||
echo "sending USR2"
|
||||
kill -USR2 $$
|
||||
|
||||
trap "" USR2
|
||||
echo "sending USR2"
|
||||
kill -USR2 $$
|
||||
|
||||
trap "-" USR2
|
||||
echo "sending USR2"
|
||||
kill -USR2 $$
|
||||
|
||||
echo "not reached"
|
||||
'
|
||||
|
||||
trap "-" USR1 USR2
|
2
shell/hush_test/hush-trap/exit.right
Normal file
2
shell/hush_test/hush-trap/exit.right
Normal file
@ -0,0 +1,2 @@
|
||||
cow
|
||||
moo
|
3
shell/hush_test/hush-trap/exit.tests
Normal file
3
shell/hush_test/hush-trap/exit.tests
Normal file
@ -0,0 +1,3 @@
|
||||
hush -c 'trap "echo cow" 0'
|
||||
hush -c 'trap "echo moo" EXIT'
|
||||
hush -c 'trap "echo no" 0; trap 0'
|
2
shell/hush_test/hush-trap/save-ret.right
Normal file
2
shell/hush_test/hush-trap/save-ret.right
Normal file
@ -0,0 +1,2 @@
|
||||
YEAH
|
||||
0
|
4
shell/hush_test/hush-trap/save-ret.tests
Normal file
4
shell/hush_test/hush-trap/save-ret.tests
Normal file
@ -0,0 +1,4 @@
|
||||
# make sure we do not corrupt $? across traps
|
||||
trap "echo YEAH; false" USR1
|
||||
kill -USR1 $$
|
||||
echo $?
|
14
shell/hush_test/hush-trap/usage.right
Normal file
14
shell/hush_test/hush-trap/usage.right
Normal file
@ -0,0 +1,14 @@
|
||||
___
|
||||
___
|
||||
___
|
||||
trap -- 'a' EXIT
|
||||
trap -- 'a' INT
|
||||
trap -- 'a' USR1
|
||||
trap -- 'a' USR2
|
||||
___
|
||||
___
|
||||
trap -- 'a' USR1
|
||||
trap -- 'a' USR2
|
||||
___
|
||||
___
|
||||
trap -- 'a' USR2
|
23
shell/hush_test/hush-trap/usage.tests
Normal file
23
shell/hush_test/hush-trap/usage.tests
Normal file
@ -0,0 +1,23 @@
|
||||
# no output -- default state
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# assign some traps
|
||||
echo ___
|
||||
trap "a" EXIT INT USR1 USR2
|
||||
|
||||
# show them all
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# clear one
|
||||
echo ___
|
||||
trap 0 INT
|
||||
echo ___
|
||||
trap
|
||||
|
||||
# clear another
|
||||
echo ___
|
||||
trap "-" USR1
|
||||
echo ___
|
||||
trap
|
Loading…
Reference in New Issue
Block a user