mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-06 01:08:03 +00:00
This fixes the case where the provided paths do not contain any shell scripts, ie. xargs is passed no values. In this case by default, xargs invokes the command once with no args. This causes shellcheck to print usage and exit failure. The GNU-specific --no-run-if-empty changes the behaviour so that in this case, shellcheck is simply never run. This allows us to use this script as a general lint even in contexts where no shell scripts are present, or none of the files passed are shell scripts.
14 lines
302 B
Bash
Executable File
14 lines
302 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Lint all shell files in given directories with `shellcheck`.
|
|
#
|
|
# e.g.
|
|
# $ shell-lint infra k8s
|
|
#
|
|
# Depends on:
|
|
# - shellcheck
|
|
# - files-with-type
|
|
# - file >= 5.22
|
|
|
|
"$(dirname "${BASH_SOURCE[0]}")/files-with-type" text/x-shellscript "$@" | xargs --no-run-if-empty shellcheck
|