# It's like makefile/justfile but using a simple script! # usage: run # 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 }