From b24f4094550ccb856154efd41927b957478bc5a1 Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Wed, 1 Jun 2022 18:17:28 +0300 Subject: [PATCH] add possibility to run multiple targets --- bake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bake b/bake index a2d1cce..c8857fb 100755 --- a/bake +++ b/bake @@ -62,6 +62,10 @@ Bash-Make: bake -m Menu of targets with 'smenu' command __autocomplete__ get autocomplete function for bash + Targets can get arguments, read from the command line. + Multiple targets can be run by passing them comma separated, but second + arguments can not be used in that case. + Example Bakefile # help() { # This help. Note the exact function declaration + docs format. # # function names may contain characters: a-zA-Z0-9._- @@ -153,7 +157,7 @@ else # Argument is one of the targets: echo "Running target: $1" >&2 "$@" - elif [[ "$1" =~ "_complete_"* ]]; then + elif [[ "$1" =~ "_complete_".* ]]; then if [[ "$( type -t $1 )" = function ]]; then # target is a command line completer "$@" @@ -161,6 +165,12 @@ else # but there is no defined completion compgen -f -d -- "${@: -1}" fi + elif [[ "$1" =~ .*",".* ]]; then + # Target is comma separated, run individually. + IFS=',' read -ra CMDLIST <<< "$1" + for CMD in "${CMDLIST[@]}"; do + "$0" "$CMD" + done else # no such command echo "Command '$1' not recognized" >&2