]> git.cworth.org Git - gzip/blob - zforce.in
Imported Debian patch 1.3.5-10sarge1
[gzip] / zforce.in
1 :
2 #!/bin/sh
3 # zforce: force a gz extension on all gzip files so that gzip will not
4 # compress them twice.
5 #
6 # This can be useful for files with names truncated after a file transfer.
7 # 12345678901234 is renamed to 12345678901.gz
8
9
10 # Copyright (C) 2002 Free Software Foundation
11 # Copyright (C) 1993 Jean-loup Gailly
12
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)
16 # any later version.
17
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.
22
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
26 # 02111-1307, USA.
27
28
29 PATH="BINDIR:$PATH"; export PATH
30 x=`basename $0`
31 if test $# = 0; then
32   echo "force a '.gz' extension on all gzip files"
33   echo usage: $x files...
34   exit 1
35 fi
36
37 res=0
38 for i do
39   if test ! -f "$i" ; then
40     echo ${x}: $i not a file
41     res=1
42     continue
43   fi
44
45   case "$i" in
46   *[-.]z | *[-.]gz | *.t[ag]z) continue;;
47   esac
48
49   if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
50
51     new="$i.gz"
52     if mv "$i" "$new"; then
53       echo $i -- replaced with $new
54     else
55       res=$?
56     fi
57   fi
58 done
59 exit $res