summaryrefslogtreecommitdiffstats
path: root/tools/fix-eof-eol.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/fix-eof-eol.sh')
-rwxr-xr-xtools/fix-eof-eol.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/fix-eof-eol.sh b/tools/fix-eof-eol.sh
new file mode 100755
index 0000000..a077c85
--- /dev/null
+++ b/tools/fix-eof-eol.sh
@@ -0,0 +1,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