1 #
2 # Test the if statement
3
4 #### If
5 if true; then
6 echo if
7 fi
8 ## stdout: if
9
10 #### else
11 if false; then
12 echo if
13 else
14 echo else
15 fi
16 ## stdout: else
17
18 #### elif
19 if (( 0 )); then
20 echo if
21 elif true; then
22 echo elif
23 else
24 echo else
25 fi
26 ## stdout: elif
27
28 #### Long style
29 if [[ 0 -eq 1 ]]
30 then
31 echo if
32 echo if
33 elif true
34 then
35 echo elif
36 else
37 echo else
38 echo else
39 fi
40 ## stdout: elif
41
42
43 #### if break corner case
44
45 ## This is analogous to the 'while' case in spec/loop
46 f() {
47 if break; then
48 echo hi
49 fi
50 }
51 f
52 ## STDOUT:
53 hi
54 ## END
55 ## BUG zsh stdout-json: ""
56 ## BUG zsh status: 1