dotfiles/.bash_it/hooks/dot-sh.sh
2022-02-27 20:00:49 +01:00

22 lines
400 B
Bash
Executable File

#!/usr/bin/env bash
exit_code=0
for file in "$@"; do
# Confirm file is executable
#
if [[ ! -x "${file}" ]]; then
echo "Bash file \`${file}\` is not executable"
exit_code=1
fi
# Confirm expected #! header
#
LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "#!/usr/bin/env bash" ]]; then
echo "Bash file \`${file}\` has bad/missing #! header"
exit_code=1
fi
done
exit $exit_code