diff options
author | classabbyamp <void@placeviolette.net> | 2024-01-21 01:48:44 -0500 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2024-01-25 13:50:35 +0100 |
commit | 45cf3ff916a551f42c6bcb2e2101042b58cd0ef8 (patch) | |
tree | 1e7c418aabc2b4ef60ea4f8515aa8fd01bbe5b37 | |
parent | 94d1bc949192f819ffaab475c488068628dceade (diff) | |
download | xtools-45cf3ff916a551f42c6bcb2e2101042b58cd0ef8.tar.gz xtools-45cf3ff916a551f42c6bcb2e2101042b58cd0ef8.tar.xz xtools-45cf3ff916a551f42c6bcb2e2101042b58cd0ef8.zip |
xlint: improve missing/multiply defined messages v0.66
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
-rwxr-xr-x | xlint | 7 |
1 files 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 } |