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

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