1# andor-p.tst: test of and-or lists for any POSIX-compliant shell
2
3posix="true"
4
5test_oE -e 0 '2-command list, success && success'
6echo 1 && echo 2
7__IN__
81
92
10__OUT__
11
12test_oE -e 0 '2-command list, success || success'
13echo 1 || echo 2
14__IN__
151
16__OUT__
17
18test_oE -e n '2-command list, failure && success'
19false && echo 2
20__IN__
21__OUT__
22
23test_oE -e 0 '2-command list, failure || success'
24false || echo 2
25__IN__
262
27__OUT__
28
29test_oE -e n '2-command list, success && failure'
30echo 1 && false
31__IN__
321
33__OUT__
34
35test_oE -e 0 '2-command list, success || failure'
36echo 1 || false
37__IN__
381
39__OUT__
40
41test_oE -e n '2-command list, failure && failure'
42false && false
43__IN__
44__OUT__
45
46test_oE -e n '2-command list, failure || failure'
47false || false
48__IN__
49__OUT__
50
51test_oE '3-command list'
52false && echo foo || echo bar
53true || echo foo && echo bar
54__IN__
55bar
56bar
57__OUT__
58
59test_x -e 0 'exit status of list is from last-executed pipeline (success)'
60false && exit 1 || true || exit 1 || exit 2
61__IN__
62
63test_x -e 13 'exit status of list is from last-executed pipeline (failure)'
64true && (exit 1) || true || exit || exit && (exit 13) && exit 20 && exit 21
65__IN__
66
67test_o 'linebreak after &&'
68echo 1 &&
69    echo 2 &&
70
71    echo 3
72__IN__
731
742
753
76__OUT__
77
78test_o 'linebreak after ||'
79false ||
80    false ||
81
82    echo foo
83__IN__
84foo
85__OUT__
86
87test_o 'pipelines in list'
88! false && ! true | false && echo foo | cat
89__IN__
90foo
91__OUT__
92
93# vim: set ft=sh ts=8 sts=4 sw=4 noet:
94