Skip to content

Instantly share code, notes, and snippets.

@strboul
Created August 18, 2018 21:09
Show Gist options
  • Save strboul/553139d91ffaeb89f431c6f43b4a5450 to your computer and use it in GitHub Desktop.
Save strboul/553139d91ffaeb89f431c6f43b4a5450 to your computer and use it in GitHub Desktop.
Automate linting for bash files (add to CI).
#!/bin/bash -e
if ! [ -x "$(command -v shellcheck)" ]; then
echo 'Program ShellCheck not found. Aborting.' >&2
exit 1
fi
# finds either .sh or .bin files
if find . -type f \( -iname \*.sh -o -iname \*.bin \) -print0 | xargs -n1 -0 shellcheck -s bash; then
echo -e "ShellCheck lint test passed!"
else
echo -e >&2 "ShellCheck lint test failed!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment