]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | if : ; 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 | |
16 | fi | |
ccc6cda3 JA |
17 | # command subst should not inherit -e |
18 | set -e | |
19 | echo $(false; echo ok) | |
d166f048 JA |
20 | |
21 | if set +e | |
22 | then | |
23 | false | |
24 | fi | |
25 | echo hi | |
26 | ||
27 | set -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 | ||
32 | while false; do | |
33 | echo hi | |
34 | done | |
35 | echo while succeeded | |
36 | ||
37 | x=1 | |
38 | until (( x == 4 )); do | |
39 | x=4 | |
40 | done | |
41 | echo until succeeded: $x | |
42 | ||
43 | if false; then | |
44 | echo oops | |
45 | fi | |
46 | echo if succeeded | |
47 | ||
48 | # failing commands that are part of an AND or OR list should not | |
49 | # cause the shell to exit | |
50 | false && echo AND list failed | |
51 | echo AND list succeeded | |
52 | ||
53 | false || echo OR list succeeded | |
54 | ||
55 | ! false | |
56 | echo ! succeeded | |
57 | ||
58 | # make sure eval preserves the state of the -e flag and `!' reserved word | |
59 | set -e | |
60 | if eval false; then | |
61 | echo oops | |
62 | fi | |
63 | echo eval succeeded | |
64 | ||
65 | ! eval false | |
66 | echo ! eval succeeded -- 1 | |
67 | ||
68 | ! eval '(exit 5)' | |
69 | echo ! eval succeeded -- 2 |