OILS / spec / if_.test.sh View on Github | oilshell.org

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