#!/usr/bin/sh # Copyright (c) 2004 # Kevin Atkinson # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without # fee, provided that the above copyright notice appear in all copies # and that both that copyright notice and this permission notice # appear in supporting documentation. Kevin Atkinson makes no # representations about the suitability of this software for any # purpose. It is provided "as is" without express or implied # warranty. cmd=`basename "$0"` warn () { if test -z "$quiet"; then echo "$cmd: $1" >&2 ; fi } error () { echo "$cmd: $1" >&2 errors=t } zip2 () { case $1 in d) prezip-bin -d "$cmd: $2" ;; z) if test "$sort" then LC_COLLATE=C sort -u | prezip-bin -z "$cmd: $2" else prezip-bin -z "$cmd: $2" fi ;; esac if test $? -eq 0 then return 0 else errors=t return 1 fi } zip () { if test -e "$3" -a ! "$force" then error "Output file $3 already exists." return 1 fi zip2 $1 "$2: " < "$2" > "$3" if test $? -eq 0 then if test -z "$keep"; then rm "$2"; fi return 0 else rm "$3" return 1 fi } case $cmd in prezip) mode=z ;; preunzip) mode=d ;; precat) mode=d; stdout=t ;; *) mode=h ;; esac num=0 for p do case $p in --*) parm=`expr "x$p" : '...\(.*\)'` case $parm in decompress ) mode=d ;; compress ) mode=z ;; keep ) keep=t ;; force ) force=t ;; stdout ) stdout=t ;; sort ) sort=t ;; nocwl ) nocwl=t ;; license ) mode=L ;; version ) mode=V ;; help ) mode=h ;; quiet ) quiet=t ;; * ) error "invalid option -- $parm";; esac ;; -* ) p=`expr "x$p" : '..\(.*\)'` while test "$p" do parm=`expr "$p" : '\(.\)'` p=`expr "$p" : '.\(.*\)'` case $parm in d ) mode=d ;; z ) mode=z ;; k ) keep=t ;; f ) force=t ;; c ) stdout=t ;; s ) sort=t ;; S ) nocwl=t ;; L ) mode=L ;; V ) mode=V ;; h ) mode=h ;; q ) quiet=t ;; * ) error "invalid option -- $parm";; esac done ;; * ) num=`expr $num + 1` ;; esac done if test "$errors" then mode=h fi case $mode in h ) prezip-bin -V cat <