1*86d7f5d3SJohn Marino#!/bin/sh - 2*86d7f5d3SJohn Marino# 3*86d7f5d3SJohn Marino# $NetBSD: zforce,v 1.2 2003/12/28 12:43:43 wiz Exp $ 4*86d7f5d3SJohn Marino# $DragonFly: src/usr.bin/gzip/zforce,v 1.1 2004/10/26 11:19:31 joerg Exp $ 5*86d7f5d3SJohn Marino# $OpenBSD: zforce,v 1.2 2003/08/05 18:22:17 deraadt Exp $ 6*86d7f5d3SJohn Marino# 7*86d7f5d3SJohn Marino# Copyright (c) 2003 Otto Moerbeek <otto@drijf.net> 8*86d7f5d3SJohn Marino# 9*86d7f5d3SJohn Marino# Permission to use, copy, modify, and distribute this software for any 10*86d7f5d3SJohn Marino# purpose with or without fee is hereby granted, provided that the above 11*86d7f5d3SJohn Marino# copyright notice and this permission notice appear in all copies. 12*86d7f5d3SJohn Marino# 13*86d7f5d3SJohn Marino# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14*86d7f5d3SJohn Marino# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15*86d7f5d3SJohn Marino# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16*86d7f5d3SJohn Marino# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17*86d7f5d3SJohn Marino# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18*86d7f5d3SJohn Marino# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19*86d7f5d3SJohn Marino# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20*86d7f5d3SJohn Marino# 21*86d7f5d3SJohn Marinoprog=`basename $0` 22*86d7f5d3SJohn MarinoUSAGE="usage: $prog file ..." 23*86d7f5d3SJohn Marinoif test $# -eq 0; then 24*86d7f5d3SJohn Marino echo $USAGE 25*86d7f5d3SJohn Marino exit 1 26*86d7f5d3SJohn Marinofi 27*86d7f5d3SJohn Marino 28*86d7f5d3SJohn Marinoret=0 29*86d7f5d3SJohn Marino 30*86d7f5d3SJohn Marinowhile test $# -ne 0; do 31*86d7f5d3SJohn Marino case "$1" in 32*86d7f5d3SJohn Marino *[._-]gz) 33*86d7f5d3SJohn Marino shift 34*86d7f5d3SJohn Marino ;; 35*86d7f5d3SJohn Marino *.t[ag]z) 36*86d7f5d3SJohn Marino shift 37*86d7f5d3SJohn Marino ;; 38*86d7f5d3SJohn Marino *) 39*86d7f5d3SJohn Marino if file "$1" | 40*86d7f5d3SJohn Marino grep -q "gzip compressed data" 2> /dev/null 41*86d7f5d3SJohn Marino then 42*86d7f5d3SJohn Marino n="$1".gz 43*86d7f5d3SJohn Marino if mv "$1" "$n" 2> /dev/null; then 44*86d7f5d3SJohn Marino echo "$1" -- renamed to "$n" 45*86d7f5d3SJohn Marino else 46*86d7f5d3SJohn Marino ret=1 47*86d7f5d3SJohn Marino echo $prog: cannot rename "$1" to "$n" 48*86d7f5d3SJohn Marino fi 49*86d7f5d3SJohn Marino fi 50*86d7f5d3SJohn Marino shift 51*86d7f5d3SJohn Marino ;; 52*86d7f5d3SJohn Marino esac 53*86d7f5d3SJohn Marinodone 54*86d7f5d3SJohn Marinoexit $ret 55