From: mdw Date: Wed, 22 Oct 2003 18:23:46 +0000 (+0000) Subject: Bring `z' into the fold. X-Git-Tag: 1.1.1~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/misc/commitdiff_plain/e9d283da23d16b6b1d11dce4cfaf26ff777c9605 Bring `z' into the fold. --- diff --git a/Makefile b/Makefile index 04789bd..d74a070 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ VERSION = 1.1.0 BINSCRIPTS = \ cdb-assign cdb-list check-sender \ - unfwd splitconf + unfwd splitconf z SBINSCRIPTS = \ shadowfix @@ -14,7 +14,7 @@ SBINSCRIPTS = \ SCRIPTS = $(BINSCRIPTS) $(SBINSCRIPTS) BINPROGS = \ - not \ + not \ cdb-probe cdb-check-domain \ gorp \ locking if-mtu @@ -30,7 +30,7 @@ LIBS = \ xtitle.so MAN1 = \ - not.1 \ + not.1 z.1 \ cdb-assign.1 cdb-list.1 cdb-probe.1 cdb-check-domain.1 \ gorp.1 \ unfwd.1 splitconf.1 locking.1 if-mtu.1 diff --git a/z b/z new file mode 100755 index 0000000..c74b027 --- /dev/null +++ b/z @@ -0,0 +1,43 @@ +#! /bin/bash + +me="${0##*/}" + +if [ $# -lt 1 ]; then + echo >&2 "Usage: $me command [args]" + exit 1 +fi + +tmp=${TMPDIR-/tmp}/zz.$$ +mkdir -m700 $tmp || exit 1 + +# --- Snarfle the arguments --- + +declare -a cmd +declare -i i seq + +cmd[0]="$1"; shift + +i=1 seq=0 +for j; do + file="$1"; shift + case "$file" in + *.Z|*.z|*.gz) + gunzip -c "$file" >$tmp/zz.$seq + file=$tmp/zz.$seq + seq=seq+1 + ;; + *.bz2) + bunzip2 -c "$file" >$tmp/zz.$seq + file=$tmp/zz.$seq + seq=seq+1 + ;; + esac + cmd[i]="$file" + i=i+1 +done + +# --- Run the program --- + +"${cmd[@]}"; stat=$? +rm -rf $tmp +exit $? diff --git a/z.1 b/z.1 new file mode 100644 index 0000000..8173170 --- /dev/null +++ b/z.1 @@ -0,0 +1,34 @@ +.TH z 1 "18 February 1999" "Edgeware tools" +.SH NAME +z \- run shell commands on compressed files +.SH SYNOPSIS +.B z +.I command +.RI [ arguments ...] +.SH DESCRIPTION +The +.B z +script examines the shell command passed to it for filenames which look +as if they're compressed files. For each one that it finds, it +decompresses the file into a temporary place, and replaces the +compressed file's name in the command line with the name of the +decompressed version. When the command terminates, +.B z +deletes the decompressed files and exits. +.SH BUGS +The +.B z +program is a very simple +.B bash +shell script. As a result there are a number of limitations: +.PP +Changes made to the temporary decompressed files are ignored: the +original is left unchanged. +.PP +Nonexistent files cause errors to be reported. +.PP +The decompressed versions of files are always created with default +owner, group and permissions (as set by the current euid, egid and umask +settings). +.SH AUTHOR +Mark Wooding (mdw@nsict.org).