Files
foreman/bin/foreman-runner
2012-02-07 11:17:44 -05:00

37 lines
495 B
Bash
Executable File

#!/bin/sh
#
#/ Usage: foreman-runner [-d <dir>] <command>
#/
#/ 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) cd "$OPTARG" ;;
h) usage ;;
\?) error "invalid option: -$OPTARG" ;;
:) error "option -$OPTARG requires an argument" ;;
esac
done
shift $((OPTIND-1))
command=$1
if [ -z "$1" ]; then
usage
fi
exec $1