chiark / gitweb /
Bring `z' into the fold.
authormdw <mdw>
Wed, 22 Oct 2003 18:23:46 +0000 (18:23 +0000)
committermdw <mdw>
Wed, 22 Oct 2003 18:23:46 +0000 (18:23 +0000)
Makefile
z [new file with mode: 0755]
z.1 [new file with mode: 0644]

index 04789bda3a09579322f87327369d8ebb189d752a..d74a07068e3e416f6069a805532090773c283d8a 100644 (file)
--- 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 (executable)
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 (file)
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).