1
2
3 #### cd builtin: fatal error in block
4 shopt -s ysh:all
5 cd / {
6 echo one
7 false
8 echo two
9 }
10 ## status: 1
11 ## STDOUT:
12 one
13 ## END
14
15
16 #### cd builtin: return in block
17 shopt -s ysh:all
18 f() {
19 cd / {
20 echo one
21 return
22 echo two
23 }
24 # not reached, because we're turning out of f
25 echo 'end func'
26 }
27 f
28 ## STDOUT:
29 one
30 ## END
31
32 #### cd builtin: break in block
33 shopt -s ysh:all
34 f() {
35 cd / {
36 echo one
37 for i in 1 2; do
38 echo $i
39 break # break out of loop
40 done
41
42 break # break out of block isn't valid
43 echo two
44 }
45 echo end func
46 }
47 f
48 ## status: 1
49 ## STDOUT:
50 one
51 1
52 ## END
53
54 #### proc eval block: fatal error
55 shopt -s ysh:all
56
57 proc proc-that-runs-block (; ; ; b) {
58 call io->eval(b)
59 }
60 proc-that-runs-block {
61 echo one
62 false
63 echo two
64 }
65 ## status: 1
66 ## STDOUT:
67 one
68 ## END
69
70 #### proc eval block: return
71 shopt -s ysh:all
72
73 proc proc-that-runs-block (; ; ; b) {
74 call io->eval(b)
75 }
76
77 f() {
78 proc-that-runs-block {
79 echo one
80 return
81 echo two
82 }
83 # this is reached because we're returning of proc-that-runs-block
84 echo 'end func'
85 }
86 f
87 ## STDOUT:
88 one
89 end func
90 ## END
91
92 #### proc eval block: break in block
93 shopt -s ysh:all
94
95 proc proc-that-runs-block (; ; ; b) {
96 call io->eval(b)
97 }
98
99 f() {
100 proc-that-runs-block {
101 echo one
102 for i in 1 2; do
103 echo $i
104 break # break out of loop
105 done
106
107 break # break out of block isn't valid
108 echo two
109 }
110 echo end func
111 }
112 f
113 ## status: 1
114 ## STDOUT:
115 one
116 1
117 ## END
118
119 #### proc eval string: fatal error
120 shopt -s ysh:all
121
122 proc proc-that-evals (s) {
123 eval $s
124 }
125 proc-that-evals '
126 echo one
127 false
128 echo two
129 '
130 ## status: 1
131 ## STDOUT:
132 one
133 ## END
134
135 #### proc eval string: return
136 shopt -s ysh:all
137
138 proc proc-that-evals (s) {
139 eval $s
140 }
141
142 f() {
143 proc-that-evals '
144 echo one
145 return
146 echo two
147 '
148 # this is reached because we're returning of proc-that-evals
149 echo 'end func'
150 }
151 f
152 ## STDOUT:
153 one
154 end func
155 ## END
156
157 #### proc eval string: break
158 shopt -s ysh:all
159
160 proc proc-that-evals (s) {
161 eval $s
162 }
163
164 f() {
165 proc-that-evals '
166 echo one
167 for i in 1 2; do
168 echo $i
169 break # break out of loop
170 done
171
172 break # break out of string is not valid
173 echo two
174 '
175 echo end func
176 }
177 f
178 ## status: 1
179 ## STDOUT:
180 one
181 1
182 ## END