tests: fix "make check" failure on AIX 7.1
[gzip.git] / zforce.in
blob5baff0778d1eaa85b68f8cb1810f1aa6bb86ee6f
1 #!/bin/sh
2 # zforce: force a gz extension on all gzip files so that gzip will not
3 # compress them twice.
5 # This can be useful for files with names truncated after a file transfer.
6 # 12345678901234 is renamed to 12345678901.gz
9 # Copyright (C) 2002, 2007, 2010-2016 Free Software Foundation, Inc.
10 # Copyright (C) 1993 Jean-loup Gailly
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 3 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along
23 # with this program; if not, write to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 bindir=@bindir@
27 case $1 in
28 --__bindir) bindir=${2?}; shift; shift;;
29 esac
30 PATH=$bindir:$PATH; export PATH
32 version="zforce (gzip) @VERSION@
33 Copyright (C) 2010-2016 Free Software Foundation, Inc.
34 This is free software. You may redistribute copies of it under the terms of
35 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
36 There is NO WARRANTY, to the extent permitted by law.
38 Written by Jean-loup Gailly."
40 usage="Usage: $0 [FILE]...
41 Force a .gz extension on all compressed FILEs so that gzip will
42 not compress them twice.
44 Report bugs to <bug-gzip@gnu.org>."
46 if test $# = 0; then
47 echo >&2 "$0: invalid number of operands; try \`$0 --help' for help"
48 exit 1
51 res=0
52 for i do
53 case "$i" in
54 --h*) exec echo "$usage";;
55 --v*) exec echo "$version";;
56 *[-.]z | *[-.]gz | *.t[ag]z) continue;;
57 esac
59 if test ! -f "$i" ; then
60 echo zforce: $i not a file
61 res=1
62 continue
65 if gzip -lv < "$i" 2>/dev/null | grep '^defl' > /dev/null; then
67 new="$i.gz"
68 if mv "$i" "$new"; then
69 echo $i -- replaced with $new
70 else
71 res=$?
74 done
75 exit $res