3 # zforce: force a gz extension on all gzip files so that gzip will not
6 # This can be useful for files with names truncated after a file transfer.
7 # 12345678901234 is renamed to 12345678901.gz
10 # Copyright (C) 2002 Free Software Foundation
11 # Copyright (C) 1993 Jean-loup Gailly
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2, or (at your option)
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 PATH="BINDIR:$PATH"; export PATH
32 echo "force a '.gz' extension on all gzip files"
33 echo usage: $x files...
39 if test ! -f "$i" ; then
40 echo ${x}: $i not a file
44 test `expr "$i" : '.*[.-]z$'` -eq 0 || continue
45 test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue
46 test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue
48 if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
50 if test `expr "$i" : '^............'` -eq 12; then
51 new=`expr "$i" : '\(.*\)...$`.gz
55 if mv "$i" "$new" 2>/dev/null; then
56 echo $i -- replaced with $new
59 res=1; echo ${x}: cannot rename $i to $new