Add support for setting the base directory

This commit is contained in:
Pierre Pronchery 2020-02-24 06:48:23 +01:00
parent 413a23c405
commit d2b6186736

View File

@ -153,15 +153,16 @@ _error()
#usage
_usage()
{
echo "Usage: $PROGNAME_JOBS add command" 1>&2
echo " $PROGNAME_JOBS exec" 1>&2
echo " $PROGNAME_JOBS list" 1>&2
echo "Usage: $PROGNAME_JOBS [-d directory] add command" 1>&2
echo " $PROGNAME_JOBS [-d directory] exec" 1>&2
echo " $PROGNAME_JOBS [-d directory] list" 1>&2
return 1
}
#main
while getopts "DO:" name; do
directory=
while getopts "DO:d:" name; do
case "$name" in
D)
DEBUG="_debug"
@ -169,6 +170,9 @@ while getopts "DO:" name; do
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
d)
directory="$OPTARG"
;;
?)
_usage
exit $?
@ -194,4 +198,8 @@ case "$1" in
esac
shift
if [ -n "$directory" ]; then
(cd "$directory" && "$method" "$@")
else
"$method" "$@"
fi