maint: zforce and zmore exit status cleanup
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 25 Nov 2017 06:34:05 +0000 (22:34 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 25 Nov 2017 06:34:29 +0000 (22:34 -0800)
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.

zforce.in
zmore.in

index f0ff71ca3cc9048df6d05afb7691a65c184806d8..672ffceeed99e7c8cf9df2249dc4c9c6c49cf7ae 100644 (file)
--- 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
index 1bd3bdb737459d506c5e4f760551ca156d0b27e8..b9f0b7dc77b0519b5e71987816f87e88ce8f829b 100644 (file)
--- 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 <bug-gzip@gnu.org>."
 
 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;;