chore: add a script to find files without new line at EOF

This commit is contained in:
Zaiming Shi 2021-11-04 14:39:27 +01:00
parent 85b41a112c
commit 6f3cfbc102
1 changed files with 26 additions and 0 deletions

26
scripts/check-nl-at-eof.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
set -euo pipefail
cd -P -- "$(dirname -- "$0")/.."
nl_at_eof() {
local file="$1"
if ! [ -f $file ]; then
return
fi
case "$file" in
*.png|*rebar3)
return
;;
esac
local lastbyte
lastbyte="$(tail -c 1 "$file" 2>&1)"
if [ "$lastbyte" != '' ]; then
echo $file
fi
}
while read -r file; do
nl_at_eof "$file"
done < <(git ls-files)