Files
mgmt/test/test-bashfmt.sh
James Shubin 72681349e5 Add a simple bashfmt test
If someone ever made a bashfmt script, that would be a lovely hack!
2016-02-08 12:06:46 -05:00

32 lines
569 B
Bash
Executable File

#!/bin/bash
# check for any bash files that aren't properly formatted
# TODO: this is hardly exhaustive
set -o errexit
set -o nounset
set -o pipefail
ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${ROOT}"
find_files() {
git ls-files | grep -e '\.sh$' -e '\.bash$'
}
bad_files=$(
for i in $(find_files); do
# search for more than one leading space, to ensure we use tabs
if grep -q '^ ' "$i"; then
echo "$i"
fi
done
)
if [[ -n "${bad_files}" ]]; then
echo 'FAIL'
echo 'The following bash files are not properly formatted:'
echo "${bad_files}"
exit 1
fi