summaryrefslogtreecommitdiffstats
path: root/tools/fix-eof-eol.sh
blob: a077c85f7f4ea2565fcd6854c770c7e000c9d16e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

# Formats files to have one newline at the end of file

for file in $@; do
awk '/^$/ { ws++; next; }

{
    for (i = 0; i < ws; ++i) { print ""; }
    print $0;
    ws = 0;
}

END {
    print "";
}' $file > ${file}.out && mv ${file}.out $file
done