Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.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: src/gnu/usr.bin/gzip/zforce,v 1.5 1999/08/27 23:35:55 peter Exp $
9 # $DragonFly: src/gnu/usr.bin/gzip/Attic/zforce,v 1.2 2003/06/17 04:25:46 dillon Exp $
10
11 x=`basename $0`
12 if test $# = 0; then
13   echo "force a '.gz' extension on all gzip files"
14   echo usage: $x files...
15   exit 1
16 fi
17
18 res=0
19 for i do
20   if test ! -f "$i" ; then
21     echo ${x}: $i not a file
22     res=1
23     continue
24   fi
25   test `expr "$i" : '.*[.-]z$'` -eq 0 || continue
26   test `expr "$i" : '.*[.-]gz$'` -eq 0 || continue
27   test `expr "$i" : '.*[.]t[ag]z$'` -eq 0 || continue
28
29   if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
30
31     new="$i.gz"
32     if mv "$i" "$new" 2>/dev/null; then
33       echo $i -- replaced with $new
34       continue
35     fi
36     res=1; echo ${x}: cannot rename $i to $new
37   fi
38 done
39 exit $res