]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/set-e-test
Imported from ../bash-2.04.tar.gz.
[thirdparty/bash.git] / tests / set-e-test
CommitLineData
726f6388
JA
1if : ; then
2 set -e
3 N=95
4 while :; do
5 # expr returns 1 if expression is null or 0
6 set +e
7 N_MOD_100=`expr $N % 100`
8 set -e
9 echo $N_MOD_100
10 N=`expr $N + 1`
11 if [ $N -eq 110 ]; then
12 break
13 fi
14 done
15 set +e
16fi
ccc6cda3
JA
17# command subst should not inherit -e
18set -e
19echo $(false; echo ok)
d166f048
JA
20
21if set +e
22then
23 false
24fi
25echo hi
26
27set -e
28
29# a failing command in the compound list following a while, until, or
30# if should not cause the shell to exit
31
32while false; do
33 echo hi
34done
35echo while succeeded
36
37x=1
38until (( x == 4 )); do
39 x=4
40done
41echo until succeeded: $x
42
43if false; then
44 echo oops
45fi
46echo if succeeded
47
48# failing commands that are part of an AND or OR list should not
49# cause the shell to exit
50false && echo AND list failed
51echo AND list succeeded
52
53false || echo OR list succeeded
54
55! false
56echo ! succeeded
57
58# make sure eval preserves the state of the -e flag and `!' reserved word
59set -e
60if eval false; then
61 echo oops
62fi
63echo eval succeeded
64
65! eval false
66echo ! eval succeeded -- 1
67
68! eval '(exit 5)'
69echo ! eval succeeded -- 2