1 | ## our_shell: ysh
|
2 | ## oils_failures_allowed: 1
|
3 |
|
4 | #### Redirect with if, case, while, for
|
5 |
|
6 | if (true) {
|
7 | echo ysh-if
|
8 | } > out
|
9 |
|
10 | cat out
|
11 |
|
12 | case (true) {
|
13 | (true) {
|
14 | echo ysh-case
|
15 | }
|
16 | } > out
|
17 |
|
18 | cat out
|
19 |
|
20 | while (true) {
|
21 | echo ysh-while
|
22 | break
|
23 | } > out
|
24 |
|
25 | cat out
|
26 |
|
27 | for x in ([42]) {
|
28 | echo ysh-for
|
29 | } > out
|
30 |
|
31 | cat out
|
32 |
|
33 | ## STDOUT:
|
34 | ysh-if
|
35 | ysh-case
|
36 | ysh-while
|
37 | ysh-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 |
|
50 | echo status=$?
|
51 |
|
52 | ## STDOUT:
|
53 | ## END
|
54 |
|