| 1 | #!/usr/bin/env bash |
| 2 | set -e -o pipefail |
| 3 | |
| 4 | shfmtflags="-bn -ci -sr" |
| 5 | # NOTE: `git grep '^#!'` may also pick up non-shell script files. |
| 6 | # Add exceptional files to `egrep -v` if any false-positive is detected. |
| 7 | if git grep --name-only '^#!' | egrep -v '(vendor|\.go|Jenkinsfile|\.py|\.bats)' \ |
| 8 | | xargs shfmt -d $shfmtflags; then |
| 9 | echo 'Congratulations! The shell scripts are properly formatted.' |
| 10 | else |
| 11 | echo "Please reformat the shell scripts with \`shfmt -w ${shfmtflags}\`." |
| 12 | exit 1 |
| 13 | fi |