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