mtimeout.1: Use correct dash for number ranges.
[misc] / buf
CommitLineData
3770fe80 1#! /bin/sh
2
3set -e
8b628e9f
MW
4ext=""
5while :; do
6 case "$#:$1" in
7 0:* | *:-h | *:--help)
8 echo "Usage: $0 [-e EXT] PROG ARGS..."
9 echo " Buffer stdin to temp file and pass to PROG with ARGS"
10 exit 0
11 ;;
12 1:-e) echo >&2 "$0: missing argument"; exit 1 ;;
13 *:-e) ext=$2; shift 2 ;;
14 *:-e*) ext=${1#-e}; shift ;;
15 *:--) shift; break ;;
16 *:-*) echo >&2 "$0: unknown option \`$1'"; exit 1 ;;
17 *) break ;;
18 esac
19done
3770fe80 20tmp=${TMPDIR-/tmp}/buf-$$
21mkdir "$tmp"
22trap 'rm -rf "$tmp"' INT QUIT TERM HUP EXIT
8b628e9f
MW
23cat >"$tmp/buf$ext"
24set +e; "$@" "$tmp/buf$ext"; st=$?; set -e
3770fe80 25trap '' INT QUIT TERM HUP EXIT
26rm -rf "$tmp"
27exit $st