1 |
#!/usr/bin/env 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 |
|
19 |
#### Redirect on assignment (enabled 7/2019) |
20 |
f() { |
21 |
# NOTE: local treated like a special builtin! |
22 |
local E=env > _tmp/r.txt |
23 |
} |
24 |
rm -f _tmp/r.txt |
25 |
f |
26 |
test -f _tmp/r.txt && echo REDIRECTED |
27 |
## status: 0 |
28 |
## stdout: REDIRECTED |
29 |
|
30 |
#### Prefix env on control flow |
31 |
for x in a b c; do |
32 |
echo $x |
33 |
E=env break |
34 |
done |
35 |
## status: 0 |
36 |
## stdout: a |
37 |
## OK osh status: 2 |
38 |
## OK osh stdout-json: "" |
39 |
|
40 |
#### Redirect on control flow |
41 |
rm -f _tmp/r.txt |
42 |
for x in a b c; do |
43 |
break > _tmp/r.txt |
44 |
done |
45 |
test -f _tmp/r.txt && echo REDIRECTED |
46 |
## status: 0 |
47 |
## stdout: REDIRECTED |
48 |
## OK osh status: 2 |
49 |
## OK osh stdout-json: "" |