diff options
author | Gonzalo TornarĂa <tornaria@cmat.edu.uy> | 2022-02-20 11:54:01 -0300 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-02-20 16:56:38 +0100 |
commit | 97b7b55dfdf2df95f37e46625202aa9a8cf1ffc8 (patch) | |
tree | 1e3a0b0094badbb4a98c79748eebfafe56c6cd72 /xlint | |
parent | d3b0cdd3b741bd7163f513bf10f97687bfb133ff (diff) | |
download | xtools-97b7b55dfdf2df95f37e46625202aa9a8cf1ffc8.tar.gz xtools-97b7b55dfdf2df95f37e46625202aa9a8cf1ffc8.tar.xz xtools-97b7b55dfdf2df95f37e46625202aa9a8cf1ffc8.zip |
xlint: improvements to lint from git index
- do not leak $tmpfile in output from scan() - indent using tabs - add new options to README
Diffstat (limited to 'xlint')
-rwxr-xr-x | xlint | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/xlint b/xlint index 3c37558..191d51e 100755 --- a/xlint +++ b/xlint @@ -9,7 +9,7 @@ scan() { local rx="$1" msg="$2" grep -P -Hn -e "$rx" "$template" | grep -v -P -e "[^:]*:[^:]*:\s*#" | - sed "s/^\([^:]*:[^:]*:\)\(.*\)/\1 $msg/" + sed "s/^[^:]*:\([^:]*\):\(.*\)/$argument:\1: $msg/" } once() { @@ -349,19 +349,20 @@ void_packages="$(xdistdir 2>/dev/null)/" ret=0 if [ "$1" = ":" ]; then - # get a list of all templates staged in the git index + # get a list of all templates staged in the git index set -- $(git -C "$void_packages" diff --cached --name-only | - sed -ne 's|^srcpkgs/\([^/]*\)/template$|:\1|p') + sed -ne 's|^srcpkgs/\([^/]*\)/template$|:\1|p') fi for argument; do template= if [ -f "$argument" ]; then template="$argument" - elif [ "${argument#:}" != "$argument" ]; then + elif [ "${argument#:}" != "$argument" ]; then trap "rm -- ${tmpfile:=$(mktemp)}" EXIT INT TERM - git -C "$void_packages" show ":srcpkgs/${argument#:}/template" \ - > ${template:=$tmpfile} || continue + # get template as staged in the git index + git -C "$void_packages" show ":srcpkgs/${argument#:}/template" \ + > ${template:=$tmpfile} || continue else _template="${void_packages}srcpkgs/$argument/template" [ -f "$_template" ] && template="$_template" @@ -460,6 +461,6 @@ for argument; do file_end else echo no such template "$argument" 1>&2 - fi | sort -t: -n -k2 | grep . && ret=1 + fi | sort -t: -n -k2 -k3 | grep . && ret=1 done exit $ret |