Debian Codegraph @

cmd/shfmt/testdata/script/flags.txtar

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 exec shfmt -h
2 ! stderr 'flag provided but not defined'
3 stderr 'usage: shfmt'
4 stderr 'Utilities' # definitely includes our help text
5 ! stderr 'help requested' # don't duplicate usage output
6 ! stderr '-test\.' # don't show the test binary's usage func
7
8 exec shfmt --help
9 stderr 'usage: shfmt'
10
11 exec shfmt -version
12 stdout 'devel|v3'
13 ! stderr .
14
15 exec shfmt --version
16 stdout 'devel|v3'
17 ! stderr .
18
19 ! exec shfmt -ln=bash -p
20 stderr 'cannot coexist'
21
22 ! exec shfmt --language-dialect=bash --posix
23 stderr 'cannot coexist'
24
25 ! exec shfmt -ln=bad
26 stderr 'unknown shell language'
27
28 ! exec shfmt --to-json file
29 stderr '--to-json can only be used with stdin'
30
31 ! exec shfmt --from-json .
32 stderr '--from-json can only be used with stdin'
33
34 ! exec shfmt -filename=foo file
35 stderr '-filename can only be used with stdin'
36
37 # Check all the -ln variations.
38
39 stdin input-posix
40 ! exec shfmt
41
42 stdin input-posix
43 exec shfmt -ln=posix
44 stdout 'let'
45
46 stdin input-posix
47 exec shfmt -p
48 stdout 'let'
49
50 stdin input-posix
51 ! exec shfmt -ln=mksh
52
53 stdin input-posix
54 ! exec shfmt -ln=bash
55
56 stdin input-mksh
57 exec shfmt -ln=mksh
58 stdout 'coprocess'
59
60 stdin input-mksh
61 ! exec shfmt
62
63 # Ensure that the default "bash" language works with and without flags.
64 stdin input-bash
65 exec shfmt
66 stdout loop
67
68 # Ensure that -ln=auto works on stdin via filename.
69 stdin input-mksh
70 exec shfmt -filename=input.mksh
71 stdout 'coprocess'
72
73 # Ensure that -ln=auto works on stdin via shebang.
74 stdin input-mksh-shebang
75 exec shfmt
76 stdout 'coprocess'
77
78 # Ensure that -ln=auto works on stdin using the fallback.
79 stdin input-bash
80 exec shfmt
81 stdout 'loop'
82
83 # The default -ln=auto shouldn't require an extension or shebang,
84 # as long as we're explicitly formatting a file.
85 exec shfmt input-tiny
86 stdout foo
87
88 # -ln=auto should prefer a shebang if the extension is only ".sh".
89 stdin input-mksh-shebang
90 exec shfmt -filename=input.sh
91 stdout 'coprocess'
92
93 # An explicit -ln=auto should still work.
94 stdin input-mksh
95 exec shfmt -ln=auto -filename=input.mksh
96 stdout 'coprocess'
97
98 # Certain filenames are recognised like an extension.
99 stdin input-zsh
100 exec shfmt -filename=/etc/zprofile
101 stdout '\${}'
102 cp input-zsh .zshrc
103 exec shfmt .zshrc
104 stdout '\${}'
105
106 # Explicitly state language on parse errors
107 stdin input-bash-arrays
108 ! exec shfmt -ln=auto -filename=input.sh
109 stderr 'parsed as posix via -ln=auto'
110
111 stdin input-bash-extglobs
112 ! exec shfmt -filename=input.sh
113 stderr 'parsed as posix via -ln=auto'
114
115 stdin flags-input
116 exec shfmt -i 2
117 cmp stdout flags-output.indent-golden
118
119 stdin flags-input
120 exec shfmt --indent 2
121 cmp stdout flags-output.indent-golden
122
123 stdin flags-input
124 exec shfmt -bn
125 cmp stdout flags-output.binary-next-line-golden
126
127 stdin flags-input
128 exec shfmt --binary-next-line
129 cmp stdout flags-output.binary-next-line-golden
130
131 stdin flags-input
132 exec shfmt -ci
133 cmp stdout flags-output.case-indent-golden
134
135 stdin flags-input
136 exec shfmt --case-indent
137 cmp stdout flags-output.case-indent-golden
138
139 stdin flags-input
140 exec shfmt -sr
141 cmp stdout flags-output.space-redirects-golden
142
143 stdin flags-input
144 exec shfmt --space-redirects
145 cmp stdout flags-output.space-redirects-golden
146
147 stdin flags-input
148 exec shfmt -kp
149 cmp stdout flags-output.keep-padding-golden
150
151 stdin flags-input
152 exec shfmt --keep-padding
153 cmp stdout flags-output.keep-padding-golden
154
155 stdin flags-input
156 exec shfmt -fn
157 cmp stdout flags-output.func-next-line-golden
158
159 stdin flags-input
160 exec shfmt --func-next-line
161 cmp stdout flags-output.func-next-line-golden
162
163 -- input-posix --
164 let a+
165 -- input-bash --
166 for ((;;)); do loop; done
167 -- input-tiny --
168 foo
169 -- input-mksh --
170 coprocess |&
171 -- input-zsh --
172 ${} =(bar)
173 -- input-mksh-shebang --
174 #!/bin/mksh
175 coprocess |&
176 -- input-bash-extglobs --
177 #!/bin/sh
178 echo !(a)
179 -- input-bash-arrays --
180 #!/bin/sh
181 foo=(bar)
182
183 -- flags-input --
184 foo() {
185 bar &&
186 baz
187
188 case $i in
189 j)
190 z
191 ;;
192 esac
193
194 space >redirs
195
196 keep padding
197 }
198 -- flags-output.indent-golden --
199 foo() {
200 bar &&
201 baz
202
203 case $i in
204 j)
205 z
206 ;;
207 esac
208
209 space >redirs
210
211 keep padding
212 }
213 -- flags-output.binary-next-line-golden --
214 foo() {
215 bar \
216 && baz
217
218 case $i in
219 j)
220 z
221 ;;
222 esac
223
224 space >redirs
225
226 keep padding
227 }
228 -- flags-output.case-indent-golden --
229 foo() {
230 bar &&
231 baz
232
233 case $i in
234 j)
235 z
236 ;;
237 esac
238
239 space >redirs
240
241 keep padding
242 }
243 -- flags-output.space-redirects-golden --
244 foo() {
245 bar &&
246 baz
247
248 case $i in
249 j)
250 z
251 ;;
252 esac
253
254 space > redirs
255
256 keep padding
257 }
258 -- flags-output.keep-padding-golden --
259 foo() {
260 bar &&
261 baz
262
263 case $i in
264 j)
265 z
266 ;;
267 esac
268
269 space >redirs
270
271 keep padding
272 }
273 -- flags-output.func-next-line-golden --
274 foo()
275 {
276 bar &&
277 baz
278
279 case $i in
280 j)
281 z
282 ;;
283 esac
284
285 space >redirs
286
287 keep padding
288 }