Bring `z' into the fold.
[misc] / z
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 $?