Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 17:48
Show Gist options
  • Save anonymous/4287263 to your computer and use it in GitHub Desktop.
Save anonymous/4287263 to your computer and use it in GitHub Desktop.
adds a newline to the end of any file that does not end in a newline
function fix-file-endings () {
for f in `git ls-files`
do
newline='
'
lastline=$(tail -n 1 $f; echo x); lastline=${lastline%x}
[ "${lastline#"${lastline%?}"}" != "$newline" ] && echo >> $f
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment