1 |
#### OSH behavior |
2 |
x=1 |
3 |
echo status=$? |
4 |
echo x=$x |
5 |
|
6 |
y = 2 |
7 |
echo status=$? |
8 |
echo y=$y |
9 |
## STDOUT: |
10 |
status=0 |
11 |
x=1 |
12 |
status=127 |
13 |
y= |
14 |
## END |
15 |
|
16 |
#### oil:upgrade behavior |
17 |
shopt --set oil:upgrade |
18 |
|
19 |
# allow errors |
20 |
set +o errexit +o nounset |
21 |
|
22 |
x=1 |
23 |
echo status=$? |
24 |
echo x=$x |
25 |
|
26 |
y = 2 |
27 |
echo status=$? |
28 |
echo y=$y |
29 |
## status: 2 |
30 |
## STDOUT: |
31 |
status=0 |
32 |
x=1 |
33 |
## END |
34 |
|
35 |
#### oil:all behavior |
36 |
shopt --set oil:all |
37 |
|
38 |
# allow errors |
39 |
set +o errexit +o nounset |
40 |
|
41 |
x=1 # fails here |
42 |
echo status=$? |
43 |
echo x=$x |
44 |
|
45 |
y = 2 |
46 |
echo status=$? |
47 |
echo y=$y |
48 |
## status: 2 |
49 |
## STDOUT: |
50 |
## END |
51 |
|
52 |
|
53 |
#### parse_equals: allows bare assignment in Caps blocks |
54 |
shopt --set parse_proc parse_brace parse_equals |
55 |
|
56 |
proc Rule { |
57 |
true |
58 |
} |
59 |
|
60 |
Rule { |
61 |
x = 1 + 2*3 |
62 |
} |
63 |
echo x=$x |
64 |
|
65 |
# still allowed since we didn't unset parse_sh_assign |
66 |
y=foo |
67 |
echo y=$y |
68 |
|
69 |
## STDOUT: |
70 |
x= |
71 |
y=foo |
72 |
## END |
73 |
|
74 |
#### bare assignment inside Hay blocks |
75 |
|
76 |
shopt --set oil:all |
77 |
|
78 |
hay define Package |
79 |
|
80 |
# problem: we would allow it here, which is weird |
81 |
|
82 |
proc p { |
83 |
var x = 42 |
84 |
} |
85 |
|
86 |
cd /tmp { |
87 |
var x = 'hi' |
88 |
} |
89 |
|
90 |
hay eval :result { |
91 |
Package { |
92 |
version = 1 |
93 |
} |
94 |
} |
95 |
|
96 |
var x = 1 |
97 |
echo "x is $x" |
98 |
|
99 |
## STDOUT: |
100 |
x is 1 |
101 |
## END |
102 |
|
103 |
|