From: Paul Eggert Date: Sat, 25 Nov 2017 06:34:05 +0000 (-0800) Subject: maint: zforce and zmore exit status cleanup X-Git-Tag: v1.9~4 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ef58a957a6c1887930cc70d6199ae7e48aa8d716;p=debian%2Fgzip maint: zforce and zmore exit status cleanup Problem reported by Nelson H. F. Beebe. * zforce.in, zmore.in: On failure, exit with status 1 instead of with whatever failing status that printf or mv exited with. --- diff --git a/zforce.in b/zforce.in index f0ff71c..672ffce 100644 --- a/zforce.in +++ b/zforce.in @@ -45,8 +45,8 @@ fi res=0 for i do case "$i" in - --h*) printf '%s\n' "$usage" ; exit;; - --v*) printf '%s\n' "$version"; exit;; + --h*) printf '%s\n' "$usage" || exit 1; exit;; + --v*) printf '%s\n' "$version" || exit 1; exit;; *[-.]z | *[-.]gz | *.t[ag]z) continue;; esac @@ -59,11 +59,7 @@ for i do if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then new="$i.gz" - if mv "$i" "$new"; then - printf '%s\n' "$i -- replaced with $new" - else - res=$? - fi + mv "$i" "$new" && printf '%s\n' "$i -- replaced with $new" || res=1 fi done exit $res diff --git a/zmore.in b/zmore.in index 1bd3bdb..b9f0b7d 100644 --- a/zmore.in +++ b/zmore.in @@ -31,8 +31,8 @@ Like 'more', but operate on the uncompressed contents of any compressed FILEs. Report bugs to ." case $1 in - --h*) printf '%s\n' "$usage" ; exit;; - --v*) printf '%s\n' "$version"; exit;; + --h*) printf '%s\n' "$usage" || exit 1; exit;; + --v*) printf '%s\n' "$version" || exit 1; exit;; --) shift;; -?*) printf >&2 '%s\n' "$0: $1: unknown option; try '$0 --help' for help" exit 1;;