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