Last active
October 25, 2018 22:15
-
-
Save ixti/70096d01b6feb700021576fe6e932dbb to your computer and use it in GitHub Desktop.
Simple shellcheck wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
files=() | |
args=() | |
hashbang_regexp="^#\\!(/bin/|/usr/bin/env )?(sh|tcsh|csh|dash|bash)" | |
function lookup() { | |
while IFS= read -d $'\0' -r file; do | |
if [[ "${file}" =~ ^.*\.(ba|c|da|tc|z)?sh$ ]] \ | |
|| head "${file}" -n 1 | grep -E -q "${hashbang_regexp}"; then | |
files=("${files[@]}" "${file}") | |
fi | |
done < <(find "$1" -type f -print0) | |
} | |
for arg in "$@"; do | |
if [[ -d "${arg}" ]]; then | |
lookup "${arg}" | |
elif [[ -f "${arg}" ]]; then | |
files=("${files[@]}" "${arg}") | |
else | |
args=("${args[@]}" "${arg}") | |
fi | |
shift | |
done | |
shellcheck "${args[@]}" "${files[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment