| #!/usr/bin/env bash | |
| set -e -o pipefail | |
| shfmtflags=(-bn -ci -sr -d "$@") # Allows to specify additional flags. | |
| # NOTE: `git grep '^#!'` may also pick up non-shell script files. | |
| # Add exceptional files to the pathspec if any false-positive is detected. | |
| if git grep --name-only '^#!' -- ':!vendor/' ':!*.py' \ | |
| | xargs shfmt "${shfmtflags[@]}"; then | |
| echo 'Congratulations! The shell scripts are properly formatted.' | |
| else | |
| echo "Please reformat the shell scripts with \`$0 -w\`." | |
| exit 1 | |
| fi |