24 lines
619 B
Bash
24 lines
619 B
Bash
|
# It's like makefile/justfile but using a simple script!
|
||
|
# usage: run <arguments passed to runfile>
|
||
|
# runfile can be placed in CWD or parents
|
||
|
|
||
|
run () {
|
||
|
local runfile
|
||
|
runfile="$(_run "$PWD")" && "$runfile" "$@"
|
||
|
}
|
||
|
|
||
|
_run () {
|
||
|
RUNFILE_DIR=$1
|
||
|
if [ ! -e "$RUNFILE_DIR/runfile" ] && [ ! -e "$RUNFILE_DIR/.runfile" ]; then
|
||
|
if [ "$RUNFILE_DIR" = "/" ]; then
|
||
|
echo "Runfile not found" 1>&2; return 1
|
||
|
else
|
||
|
_run "$(dirname $RUNFILE_DIR)"
|
||
|
fi
|
||
|
elif [ -e "$RUNFILE_DIR/runfile" ]; then
|
||
|
echo "$RUNFILE_DIR/runfile"
|
||
|
elif [ -e "$RUNFILE_DIR/.runfile" ]; then
|
||
|
echo "$RUNFILE_DIR/.runfile"
|
||
|
fi
|
||
|
}
|