1 | ## oils_failures_allowed: 1
|
2 |
|
3 | #### shopt supports long flags
|
4 | shopt -p nullglob
|
5 |
|
6 | shopt --set nullglob
|
7 | shopt -p nullglob
|
8 |
|
9 | shopt --unset nullglob
|
10 | shopt -p nullglob
|
11 |
|
12 | echo ---
|
13 | ## STDOUT:
|
14 | shopt -u nullglob
|
15 | shopt -s nullglob
|
16 | shopt -u nullglob
|
17 | ---
|
18 | ## END
|
19 |
|
20 | #### shopt supports 'set' options
|
21 | shopt -p errexit
|
22 |
|
23 | shopt --set errexit
|
24 | false
|
25 |
|
26 | echo should not get here
|
27 | ## status: 1
|
28 | ## STDOUT:
|
29 | shopt -u errexit
|
30 | ## END
|
31 |
|
32 |
|
33 | #### shopt --unset errexit { }
|
34 | shopt --set oil:all
|
35 |
|
36 | echo one
|
37 |
|
38 | shopt --unset errexit {
|
39 | echo two
|
40 | false
|
41 | echo three
|
42 | }
|
43 |
|
44 | false
|
45 | echo 'should not get here'
|
46 |
|
47 | ## status: 1
|
48 | ## STDOUT:
|
49 | one
|
50 | two
|
51 | three
|
52 | ## END
|
53 |
|
54 | #### shopt -p works correctly inside block
|
55 | shopt --set parse_brace
|
56 |
|
57 | shopt -p | grep inherit_errexit
|
58 | shopt --set inherit_errexit {
|
59 | shopt -p | grep inherit_errexit
|
60 | }
|
61 |
|
62 | ## STDOUT:
|
63 | shopt -u inherit_errexit
|
64 | shopt -s inherit_errexit
|
65 | ## END
|
66 |
|
67 |
|
68 | #### shopt --set GROUP { }
|
69 | shopt --set parse_brace
|
70 |
|
71 | shopt -p | grep errexit
|
72 | echo ---
|
73 |
|
74 | shopt --set oil:all {
|
75 | #false
|
76 | #echo status=$?
|
77 | shopt -p | grep errexit
|
78 | }
|
79 | echo ---
|
80 |
|
81 | shopt --set oil:upgrade {
|
82 | shopt -p | grep errexit
|
83 | }
|
84 | echo ---
|
85 |
|
86 | shopt --set strict:all {
|
87 | shopt -p | grep errexit
|
88 | }
|
89 |
|
90 | # TODO: shopt --table should show the error value
|
91 |
|
92 | ## STDOUT:
|
93 | shopt -u command_sub_errexit
|
94 | shopt -u inherit_errexit
|
95 | shopt -u strict_errexit
|
96 | shopt -u verbose_errexit
|
97 | ---
|
98 | shopt -s command_sub_errexit
|
99 | shopt -s inherit_errexit
|
100 | shopt -s strict_errexit
|
101 | shopt -s verbose_errexit
|
102 | ---
|
103 | shopt -s command_sub_errexit
|
104 | shopt -s inherit_errexit
|
105 | shopt -u strict_errexit
|
106 | shopt -s verbose_errexit
|
107 | ---
|
108 | shopt -u command_sub_errexit
|
109 | shopt -u inherit_errexit
|
110 | shopt -s strict_errexit
|
111 | shopt -u verbose_errexit
|
112 | ## END
|
113 |
|
114 | #### shopt and block status
|
115 | shopt --set oil:all
|
116 |
|
117 | shopt --unset errexit {
|
118 | false
|
119 | }
|
120 | # this is still 0, even though last command was 1
|
121 | echo status=$?
|
122 |
|
123 | ## STDOUT:
|
124 | status=0
|
125 | ## END
|
126 |
|
127 | #### shopt usage error
|
128 | shopt --set oil:all
|
129 |
|
130 | echo one
|
131 | shopt --set a {
|
132 | echo two
|
133 | }
|
134 | echo status=$?
|
135 | ## status: 2
|
136 | ## STDOUT:
|
137 | one
|
138 | ## END
|
139 |
|
140 | #### shopt -p
|
141 |
|
142 | shopt -p errexit
|
143 | shopt -p nullglob
|
144 |
|
145 | echo --
|
146 | shopt -p strict:all | head -n 3
|
147 |
|
148 | echo --
|
149 | shopt --set strict:all
|
150 | shopt -p strict:all | head -n 3
|
151 |
|
152 | ## STDOUT:
|
153 | shopt -u errexit
|
154 | shopt -u nullglob
|
155 | --
|
156 | shopt -u strict_argv
|
157 | shopt -u strict_arith
|
158 | shopt -u strict_array
|
159 | --
|
160 | shopt -s strict_argv
|
161 | shopt -s strict_arith
|
162 | shopt -s strict_array
|
163 | ## END
|
164 |
|
165 | #### TODO: all options as a table
|
166 |
|
167 | shopt --table
|
168 |
|
169 | # This is unlike shopt -p because
|
170 |
|
171 | # 1) It shows ALL options, not just 'shopt' options
|
172 | # 2) It shows it in QTT format?
|
173 |
|
174 | # opt_name Str value Bool
|
175 | # errexit true
|
176 | # nounset false
|
177 | #
|
178 | # Could also be T and F? JSON is more obvious
|
179 |
|
180 |
|
181 | ## STDOUT:
|
182 | ## END
|
183 |
|