From ca61eef78a27a6d0057fa435c0a855980bfb1bbe Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 29 Sep 2002 06:45:28 +0000 Subject: [PATCH] Use shell pattern matching instead of 'expr', which mishandles names 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 | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/zforce.in b/zforce.in index c7b7ef6..e44a7c5 100644 --- 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 -- 2.47.2