aboutsummaryrefslogtreecommitdiffhomepage
path: root/dev/tools/check-eof-newline.sh
blob: 9e4c8661dcf20aa20617a46bcd210bd2293883e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env bash

CODE=0
for f in "$@"; do
    if git ls-files --error-unmatch "$f" >/dev/null 2>&1 && \
           git check-attr whitespace -- "$f" | grep -q -v -e 'unset$' -e 'unspecified$' && \
           [ -n "$(tail -c 1 "$f")" ]
    then
        echo "No newline at end of file $f!"
        CODE=1
    fi
done

exit "$CODE"