Regenerte.
[debian/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 of the License, or
16 # (at your option) 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 along
24 # with this program; if not, write to the Free Software Foundation, Inc.,
25 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27 PATH="BINDIR:$PATH"; export PATH
28
29 version="zforce (gzip) @VERSION@
30 Copyright (C) 2006 Free Software Foundation, Inc.
31 This is free software.  You may redistribute copies of it under the terms of
32 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
33 There is NO WARRANTY, to the extent permitted by law.
34
35 Written by Jean-loup Gailly."
36
37 usage="Usage: zforce [FILE]...
38 Force a .gz extension on all compressed FILEs so that gzip will
39 not compress them twice.
40
41 Report bugs to <bug-gzip@gnu.org>."
42
43 if test $# = 0; then
44   echo "$usage"
45   exit 1
46 fi
47
48 res=0
49 for i do
50   case "$i" in
51   --h*) exec echo "$usage";;
52   --v*) exec echo "$version";;
53   *[-.]z | *[-.]gz | *.t[ag]z) continue;;
54   esac
55
56   if test ! -f "$i" ; then
57     echo zforce: $i not a file
58     res=1
59     continue
60   fi
61
62   if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
63
64     new="$i.gz"
65     if mv "$i" "$new"; then
66       echo $i -- replaced with $new
67     else
68       res=$?
69     fi
70   fi
71 done
72 exit $res