From 45cf3ff916a551f42c6bcb2e2101042b58cd0ef8 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Sun, 21 Jan 2024 01:48:44 -0500 Subject: xlint: improve missing/multiply defined messages these are the only messages that don't have a line number associated with them, adding complexity when parsing the output of xlint. - `'$var' missing!` only really makes sense with line number 1, as there is not really any other place to put it - `'$var' defined more than once` I decided to put on the *last* instance of the variable, and add a hint to where the previous definition(s) are --- xlint | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xlint b/xlint index 997d99d..0b1ea22 100755 --- a/xlint +++ b/xlint @@ -37,9 +37,12 @@ exists_once() { for var in pkgname version revision short_desc maintainer license \ homepage; do case "$(grep -c "^${var}=" "$template")" in - 0) echo "$argument: '$var' missing!";; + 0) echo "$argument:1: '$var' missing!";; 1) ;; - *) echo "$argument: '$var' defined more than once";; + *) + lines="$(grep -n "^${var}=" "$template" | awk -F: 'NR>1 { printf ", " } { printf "%s", $1 }')" + echo "$argument:${lines##*, }: '$var' defined more than once: previously on line(s) ${lines%,*}" + ;; esac done } -- cgit 1.4.1