]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - gnu/usr.bin/gzip/zforce
This commit was generated by cvs2svn to compensate for changes in r151970,
[FreeBSD/FreeBSD.git] / gnu / usr.bin / gzip / zforce
1 #!/bin/sh
2 # zforce: force a gz extension on all gzip files so that gzip will not
3 # compress them twice.
4 #
5 # This can be useful for files with names truncated after a file transfer.
6 # foo is renamed to foo.gz
7 #
8 # $FreeBSD$
9
10 x=`basename $0`
11 if test $# = 0; then
12   echo "force a '.gz' extension on all gzip files"
13   echo usage: $x files...
14   exit 1
15 fi
16
17 res=0
18 for i do
19   if test ! -f "$i" ; then
20     echo ${x}: $i not a file
21     res=1
22     continue
23   fi
24   test `expr "$i" : '.*[.-]z$'` -eq 0 || continue
25   test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue
26   test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue
27
28   if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
29
30     new="$i.gz"
31     if mv "$i" "$new" 2>/dev/null; then
32       echo $i -- replaced with $new
33       continue
34     fi
35     res=1; echo ${x}: cannot rename $i to $new
36   fi
37 done
38 exit $res