Use shell pattern matching instead of 'expr', which mishandles names
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 29 Sep 2002 06:45:28 +0000 (06:45 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 29 Sep 2002 06:45:28 +0000 (06:45 +0000)
like "+".  Remove old check for 14-byte file names on hosts with
broken "mv" implementations, as such systems aren't in use any more
and it's better nowadays to support file names longer than 14 bytes.

zforce.in

index c7b7ef6455eafdab4079c5d5e6482a5e7b795a5e..e44a7c519989759901019f0dcecfffdff442e47d 100644 (file)
--- a/zforce.in
+++ b/zforce.in
@@ -41,22 +41,19 @@ for i do
     res=1
     continue
   fi
-  test `expr "$i" : '.*[.-]z$'` -eq 0 || continue
-  test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue
-  test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue
+
+  case "$i" in
+  *[-.]z | *[-.]gz | *.t[ag]z) continue;;
+  esac
 
   if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
 
-    if test `expr "$i" : '^............'` -eq 12; then
-      new=`expr "$i" : '\(.*\)...$`.gz
-    else
-      new="$i.gz"
-    fi
-    if mv "$i" "$new" 2>/dev/null; then
+    new="$i.gz"
+    if mv "$i" "$new"; then
       echo $i -- replaced with $new
-      continue
+    else
+      res=$?
     fi
-    res=1; echo ${x}: cannot rename $i to $new
   fi
 done
 exit $res