OILS / spec / ysh-cmd-lang.test.sh View on Github | oilshell.org

54 lines, 25 significant
1## our_shell: ysh
2## oils_failures_allowed: 1
3
4#### Redirect with if, case, while, for
5
6if (true) {
7 echo ysh-if
8} > out
9
10cat out
11
12case (true) {
13 (true) {
14 echo ysh-case
15 }
16} > out
17
18cat out
19
20while (true) {
21 echo ysh-while
22 break
23} > out
24
25cat out
26
27for x in ([42]) {
28 echo ysh-for
29} > out
30
31cat out
32
33## STDOUT:
34ysh-if
35ysh-case
36ysh-while
37ysh-for
38## END
39
40
41#### Redirect failure is either fatal or can be checked
42
43# TODO: this fails, but there's no way to check it
44#
45# We can have shopt -s redir_errexit in YSH then?
46# Can you catch the error?
47
48{ echo 1; echo 2 } > /
49
50echo status=$?
51
52## STDOUT:
53## END
54