summary refs log tree commit diff
diff options
context:
space:
mode:
authorPiotr Wójcik <chocimier@tlen.pl>2019-07-30 22:25:51 +0200
committerLeah Neukirchen <leah@vuxu.org>2019-07-30 22:37:09 +0200
commit18a6d45c6e396a452487c9df6d8957635b1a0d07 (patch)
tree8abcb2b82b0fdd2605e7e12f3c8900fd8c55ab01
parent187c8afb95120b01bafa15a137aa09f4c10f572a (diff)
downloadxtools-18a6d45c6e396a452487c9df6d8957635b1a0d07.tar.gz
xtools-18a6d45c6e396a452487c9df6d8957635b1a0d07.tar.xz
xtools-18a6d45c6e396a452487c9df6d8957635b1a0d07.zip
xlint: assert one newline at end
Closes: #144 [via git-merge-pr]
-rwxr-xr-xxlint9
1 files changed, 9 insertions, 0 deletions
diff --git a/xlint b/xlint
index 8d4775f..0f86972 100755
--- a/xlint
+++ b/xlint
@@ -103,6 +103,14 @@ variables_order() {
 	[ "$message" ] && echo "$message"
 }
 
+file_end() {
+	if [ "$(tail -c 1 $template)" ]; then
+		echo "$template:$(( $(wc -l < $template) + 1 )): File does not end with newline character"
+	elif [ -z "$(tail -c 2 $template)" ]; then
+		echo "$template:$(wc -l < $template): Last line is empty"
+	fi
+}
+
 variables=$(echo -n "#.*
 _.*
 .*_descr
@@ -306,6 +314,7 @@ for template; do
 	scan "distfiles=.*\Q$version\E" 'use ${version} in distfiles instead'
 	variables_order
 	header
+	file_end
 	else
 	echo no such template "$template" 1>&2
 	fi | sort -t: -n -k2 | grep . && ret=1