File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 25
25
version : 3.x
26
26
27
27
- name : Lint shell scripts
28
- run : task shell:lint
28
+ run : task shell:check
Original file line number Diff line number Diff line change @@ -266,17 +266,33 @@ tasks:
266
266
cmds :
267
267
- npx {{ .PRETTIER }} --write "**/*.md"
268
268
269
- shell:lint :
270
- desc : Lint shell scripts
269
+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
270
+ shell:check :
271
+ desc : Check for problems with shell scripts
271
272
cmds :
272
273
- |
273
274
if ! which shellcheck &>/dev/null; then
274
275
echo "shellcheck not installed or not in PATH. Please install: https://github.com/koalaman/shellcheck#installing"
275
276
exit 1
276
277
fi
277
278
- |
278
- shopt -s globstar # Needed to check all scripts recursively.
279
- shellcheck ./**/*.sh
279
+ # There is something odd about shellcheck that causes the task to always exit on the first fail, despite any
280
+ # measures that would prevent this with any other command. So it's necessary to call shellcheck only once with
281
+ # the list of script paths as an argument. This could lead to exceeding the maximum command length on Windows if
282
+ # the repository contained a large number of scripts, but it's unlikely to happen in reality.
283
+ shellcheck \
284
+ --format={{default "tty" .SHELLCHECK_FORMAT}} \
285
+ $(
286
+ # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
287
+ # \ characters special treatment on Windows in an attempt to support them as path separators.
288
+ find . \
289
+ -path ".git" -prune -or \
290
+ \( \
291
+ -regextype posix-extended \
292
+ -regex '.*[.](bash|sh)' -and \
293
+ -type f \
294
+ \)
295
+ )
280
296
281
297
shell:check-formatting :
282
298
desc : Format shell scripts
You can’t perform that action at this time.
0 commit comments