Skip to content

Instantly share code, notes, and snippets.

@angristan angristan/test.sh
Created Feb 9, 2019

Embed
What would you like to do?
Lint shell executables with shellcheck
#!/bin/bash
set -e
set -o pipefail
ERRORS=()
# find all executables and run `shellcheck`
for f in $(find . -type f -not -iwholename '*.git*' | sort -u); do
if file "$f" | grep --quiet shell; then
{
shellcheck "$f" && echo "[OK]: sucessfully linted $f"
} || {
# add to errors
ERRORS+=("$f")
}
fi
done
if [ ${#ERRORS[@]} -eq 0 ]; then
echo "No errors, hooray"
else
echo "These files failed shellcheck: ${ERRORS[*]}"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.