1 |
#!/bin/bash |
2 |
# |
3 |
# Some nonsensical combinations which can all be detected at PARSE TIME. |
4 |
# All shells allow these, but right now OSH disallowed. |
5 |
# TODO: Run the parser on your whole corpus, and then if there are no errors, |
6 |
# you should make OSH the OK behavior, and others are OK. |
7 |
|
8 |
### Prefix env on assignment |
9 |
f() { |
10 |
# NOTE: local treated like a special builtin! |
11 |
E=env local v=var |
12 |
echo $E $v |
13 |
} |
14 |
f |
15 |
# status: 0 |
16 |
# stdout: env var |
17 |
# OK bash stdout: var |
18 |
# OK osh status: 2 |
19 |
# OK osh stdout-json: "" |
20 |
|
21 |
### Redirect on assignment |
22 |
f() { |
23 |
# NOTE: local treated like a special builtin! |
24 |
local E=env > _tmp/r.txt |
25 |
} |
26 |
rm -f _tmp/r.txt |
27 |
f |
28 |
test -f _tmp/r.txt && echo REDIRECTED |
29 |
# status: 0 |
30 |
# stdout: REDIRECTED |
31 |
# OK osh status: 2 |
32 |
# OK osh stdout-json: "" |
33 |
|
34 |
### Prefix env on control flow |
35 |
for x in a b c; do |
36 |
echo $x |
37 |
E=env break |
38 |
done |
39 |
# status: 0 |
40 |
# stdout: a |
41 |
# OK osh status: 2 |
42 |
# OK osh stdout-json: "" |
43 |
|
44 |
### Redirect on control flow |
45 |
rm -f _tmp/r.txt |
46 |
for x in a b c; do |
47 |
break > _tmp/r.txt |
48 |
done |
49 |
test -f _tmp/r.txt && echo REDIRECTED |
50 |
# status: 0 |
51 |
# stdout: REDIRECTED |
52 |
# OK osh status: 2 |
53 |
# OK osh stdout-json: "" |