While editing files on GitHub/Gitlab, missing an empty line at the bottom of a file in the buffer will result in no newline at the end of file. In the case of regular text files, this isn’t consistent with the POSIX standards.
for file in `git ls-files`; do grep -Iq . $file && if ! newline_at_eof $file; then; else echo $file; fi done
Fred has provided a shell script for detecting EOF on Stack Overflow.
sh because I’m using Zsh.
#!/bin/zsh if [ -z "$(tail -c 1 "$1")" ] then echo "Newline at end of file!" exit 1 else echo "No newline at end of file!" exit 0 fi