From fbdde3e62afe3e1b0e2fc0ad1abb0933155a1675 Mon Sep 17 00:00:00 2001 From: David Dollar Date: Sun, 22 Jan 2012 17:29:15 -0500 Subject: [PATCH] beef up the runner script to allow a working directory to be set --- bin/runner | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/bin/runner b/bin/runner index 69011a5..1aa648e 100755 --- a/bin/runner +++ b/bin/runner @@ -1,2 +1,37 @@ #!/bin/sh +# +#/ Usage: runner [-d ] +#/ +#/ Run a command with exec, optionally changing directory first + +set -e + +error() { + echo $@ >&2 + exit 1 +} + +usage() { + cat $0 | grep '^#/' | cut -c4- + exit +} + +while getopts ":hd:" OPT; do + case $OPT in + d) echo "cd:[$OPTARG]"; cd $OPTARG ;; + h) usage ;; + \?) error "invalid option: -$OPTARG" ;; + :) error "option -$OPTARG requires an argument" ;; + esac +done + +shift $((OPTIND-1)) + +command=$1 + +if [ "$1" == "" ]; then + usage +fi + +echo "1:[$1]" exec $1 2>&1