186d7f5d3SJohn Marino#!/bin/sh - 286d7f5d3SJohn Marino# 386d7f5d3SJohn Marino# $NetBSD: zforce,v 1.2 2003/12/28 12:43:43 wiz Exp $ 486d7f5d3SJohn Marino# $DragonFly: src/usr.bin/gzip/zforce,v 1.1 2004/10/26 11:19:31 joerg Exp $ 586d7f5d3SJohn Marino# $OpenBSD: zforce,v 1.2 2003/08/05 18:22:17 deraadt Exp $ 686d7f5d3SJohn Marino# 786d7f5d3SJohn Marino# Copyright (c) 2003 Otto Moerbeek <otto@drijf.net> 886d7f5d3SJohn Marino# 986d7f5d3SJohn Marino# Permission to use, copy, modify, and distribute this software for any 1086d7f5d3SJohn Marino# purpose with or without fee is hereby granted, provided that the above 1186d7f5d3SJohn Marino# copyright notice and this permission notice appear in all copies. 1286d7f5d3SJohn Marino# 1386d7f5d3SJohn Marino# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1486d7f5d3SJohn Marino# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1586d7f5d3SJohn Marino# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1686d7f5d3SJohn Marino# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1786d7f5d3SJohn Marino# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1886d7f5d3SJohn Marino# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1986d7f5d3SJohn Marino# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2086d7f5d3SJohn Marino# 2186d7f5d3SJohn Marinoprog=`basename $0` 2286d7f5d3SJohn MarinoUSAGE="usage: $prog file ..." 2386d7f5d3SJohn Marinoif test $# -eq 0; then 2486d7f5d3SJohn Marino echo $USAGE 2586d7f5d3SJohn Marino exit 1 2686d7f5d3SJohn Marinofi 2786d7f5d3SJohn Marino 2886d7f5d3SJohn Marinoret=0 2986d7f5d3SJohn Marino 3086d7f5d3SJohn Marinowhile test $# -ne 0; do 3186d7f5d3SJohn Marino case "$1" in 3286d7f5d3SJohn Marino *[._-]gz) 3386d7f5d3SJohn Marino shift 3486d7f5d3SJohn Marino ;; 3586d7f5d3SJohn Marino *.t[ag]z) 3686d7f5d3SJohn Marino shift 3786d7f5d3SJohn Marino ;; 3886d7f5d3SJohn Marino *) 3986d7f5d3SJohn Marino if file "$1" | 4086d7f5d3SJohn Marino grep -q "gzip compressed data" 2> /dev/null 4186d7f5d3SJohn Marino then 4286d7f5d3SJohn Marino n="$1".gz 4386d7f5d3SJohn Marino if mv "$1" "$n" 2> /dev/null; then 4486d7f5d3SJohn Marino echo "$1" -- renamed to "$n" 4586d7f5d3SJohn Marino else 4686d7f5d3SJohn Marino ret=1 4786d7f5d3SJohn Marino echo $prog: cannot rename "$1" to "$n" 4886d7f5d3SJohn Marino fi 4986d7f5d3SJohn Marino fi 5086d7f5d3SJohn Marino shift 5186d7f5d3SJohn Marino ;; 5286d7f5d3SJohn Marino esac 5386d7f5d3SJohn Marinodone 5486d7f5d3SJohn Marinoexit $ret 55