chiark / gitweb /
debian/control: Include `prlimit' and `x86-model' in the metapackage.
[misc] / z
1 #! /bin/bash
2
3 me="${0##*/}"
4
5 if [ $# -lt 1 ]; then
6   echo >&2 "Usage: $me command [args]"
7   exit 1
8 fi
9
10 tmp=${TMPDIR-/tmp}/zz.$$
11 mkdir -m700 $tmp || exit 1
12
13 # --- Snarfle the arguments ---
14
15 declare -a cmd
16 declare -i i seq
17
18 cmd[0]="$1"; shift
19
20 i=1 seq=0
21 for j; do
22   file="$1"; shift
23   case "$file" in
24     *.Z|*.z|*.gz)
25       gunzip -c "$file" >$tmp/zz.$seq
26       file=$tmp/zz.$seq
27       seq=seq+1
28       ;;
29     *.bz2)
30       bunzip2 -c "$file" >$tmp/zz.$seq
31       file=$tmp/zz.$seq
32       seq=seq+1
33       ;;
34   esac
35   cmd[i]="$file"
36   i=i+1
37 done
38
39 # --- Run the program ---
40
41 "${cmd[@]}"; stat=$?
42 rm -rf $tmp
43 exit $?