check_whitespace 318 Bytes
Newer Older
1 2 3 4 5 6 7 8
#!/bin/sh

! for f in $(git ls-files | grep -v \\.diff$); do
    file $f | grep -q ' text' || continue
    grep -q '[[:blank:]]$' $f && echo $f: trailing whitespace
    tail -n1 $f | read -r _ || echo $f: no newline at end of file
    tail -n1 $f | grep -q '^$' && echo $f: empty line at end of file
done | grep . >&2