allow dashes

This commit is contained in:
Ville Rantanen
2022-04-29 09:36:51 +03:00
parent fcd3d0ba56
commit 053b794566

7
bake
View File

@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
## VERSION 22.4.1
## BASH-MAKE ========================================================== ## BASH-MAKE ==========================================================
## Utility to mimick some of GNU Make behavior, but run in a single ## Utility to mimick some of GNU Make behavior, but run in a single
## bash shell. This executable can be used as the Bakefile, too, ## bash shell. This executable can be used as the Bakefile, too,
@@ -35,9 +36,9 @@ else
fi fi
_flines() { cat "$BAKEFILE" | \ _flines() { cat "$BAKEFILE" | \
grep -E '^([^_][a-zA-Z0-9_\.]+)\(\) {.*'; } grep -E '^([^_][a-zA-Z0-9_\.\-]+)\(\) {.*'; }
_menu() { _flines | while read line; do _menu() { _flines | while read line; do
if [[ "$line" =~ ([a-zA-Z0-9_\.]+)\(\).\{[\ #]*(.*) ]]; then if [[ "$line" =~ ([a-zA-Z0-9_\.\-]+)\(\).\{[\ #]*(.*) ]]; then
printf "\e[33m%+20s \e[36m [ %-50s ]\e[0m\n" \ printf "\e[33m%+20s \e[36m [ %-50s ]\e[0m\n" \
"${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
fi fi
@@ -90,6 +91,8 @@ Bash-Make: bake
Example Bakefile Example Bakefile
# help() { # This help. Note the exact function declaration + docs format. # help() { # This help. Note the exact function declaration + docs format.
# # function names may contain characters: a-zA-Z0-9._-
# # functions starting with _ are not listed
# _menu # _menu
# } # }
# echo foo # NOTE: Bakefile gets sourced when read! # echo foo # NOTE: Bakefile gets sourced when read!