summaryrefslogtreecommitdiffhomepage
path: root/tests/zash/errtrap.sh
blob: 4d975b54c6fb8bc8d6f995e7b679144f21b47ba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# The ERR trap runs after a command fails, where errexit would act.
trap 'echo "ERR status=$?"' ERR
false
(exit 7)
true
false || echo "or: no trap"
if false; then :; fi; echo "if: no trap"
! true; echo "not: no trap"
false | true; echo "pipe ok: no trap"
true | false
f() { return 4; }; f
x=$(false); echo "assign status=$?"
trap
trap - ERR
false; echo "removed"
trap 'echo first; false; echo "inside=$?"' ERR
false
trap 'echo e' ERR
(false; echo "in subshell: reset")
trap 'echo "then exit"' ERR
set -e
false
echo not-reached