1166255Sdelphij#!/bin/sh -
2166255Sdelphij#
3166255Sdelphij# $NetBSD: zforce,v 1.2 2003/12/28 12:43:43 wiz Exp $
4166255Sdelphij# $OpenBSD: zforce,v 1.2 2003/08/05 18:22:17 deraadt Exp $
5166255Sdelphij#
6166255Sdelphij#-
7166255Sdelphij# Copyright (c) 2003 Otto Moerbeek <otto@drijf.net>
8166255Sdelphij#
9166255Sdelphij# Permission to use, copy, modify, and distribute this software for any
10166255Sdelphij# purpose with or without fee is hereby granted, provided that the above
11166255Sdelphij# copyright notice and this permission notice appear in all copies.
12166255Sdelphij#
13166255Sdelphij# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14166255Sdelphij# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15166255Sdelphij# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16166255Sdelphij# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17166255Sdelphij# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18166255Sdelphij# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19166255Sdelphij# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20166255Sdelphij#
21166255Sdelphij# $FreeBSD$
22166255Sdelphijprog=`basename $0`
23166255SdelphijUSAGE="usage: $prog file ..."
24166255Sdelphijif test $# -eq 0; then
25166255Sdelphij	echo $USAGE
26166255Sdelphij	exit 1
27166255Sdelphijfi
28166255Sdelphij
29166255Sdelphijret=0
30166255Sdelphij
31166255Sdelphijwhile test $# -ne 0; do
32166255Sdelphij	case "$1" in
33166255Sdelphij		*[._-]gz)
34166255Sdelphij			shift
35166255Sdelphij			;;
36166255Sdelphij		*.t[ag]z)
37166255Sdelphij			shift
38166255Sdelphij			;;
39166255Sdelphij		*)
40166255Sdelphij			if file "$1" |
41166255Sdelphij				grep -q "gzip compressed data" 2> /dev/null
42166255Sdelphij			then
43166255Sdelphij				n="$1".gz
44166255Sdelphij				if mv "$1" "$n" 2> /dev/null; then
45166255Sdelphij					echo "$1" -- renamed to "$n"
46166255Sdelphij				else
47166255Sdelphij					ret=1
48166255Sdelphij					echo $prog: cannot rename "$1" to "$n"
49166255Sdelphij				fi
50166255Sdelphij			fi
51166255Sdelphij			shift
52166255Sdelphij			;;
53166255Sdelphij	esac
54166255Sdelphijdone
55166255Sdelphijexit $ret
56