hotdog/run

28 lines
511 B
Text
Raw Permalink Normal View History

2020-11-01 16:31:37 +01:00
#!/bin/sh -e
2020-11-12 23:45:20 +01:00
RUN_BIN="$0"
RUN_DIR=$(dirname "$(realpath "$0")")
2020-11-01 16:31:37 +01:00
2020-11-12 23:45:20 +01:00
export RUN_BIN
export RUN_DIR
if [ "$(dirname "$0")" = ".git/hooks" ]; then
task=$(basename "$0")
else
2020-11-01 16:31:37 +01:00
task="$1"
2020-11-12 23:45:20 +01:00
[ $# -gt 0 ] && shift
fi
script=
if [ -x "$RUN_DIR/scripts/local/$task" ]; then
script="local/$task"
elif [ -x "$RUN_DIR/scripts/git-hooks/$task" ]; then
script="git-hooks/$task"
elif [ -x "$RUN_DIR/scripts/$task" ]; then
script="$task"
2020-11-01 16:31:37 +01:00
fi
2020-11-12 23:45:20 +01:00
[ -z "$script" ] && exit 1
2020-11-01 16:31:37 +01:00
2020-11-12 23:45:20 +01:00
exec "$RUN_DIR/scripts/$script" "$@"