allow running naked

This commit is contained in:
2023-08-23 11:08:10 +03:00
parent 9c16b1af53
commit bfac4aadc6
2 changed files with 6 additions and 3 deletions

View File

@@ -72,6 +72,9 @@ _subcommand() {
echo foo # NOTE: Bakefile gets sourced when read! echo foo # NOTE: Bakefile gets sourced when read!
somevar=value somevar=value
if [ -z "$BAKEFILE" ]; then
echo This part is run if the file is sourced and not run in Bake
fi
``` ```

6
bake
View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
## VERSION 22.6.10 ## VERSION 23.8.23
## 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,
@@ -12,13 +12,13 @@ set -e
# In standalone mode, this script also contains targets # In standalone mode, this script also contains targets
STANDALONE=${STANDALONE:-false} STANDALONE=${STANDALONE:-false}
if [[ $STANDALONE = true ]]; then if [[ $STANDALONE = true ]]; then
BAKEFILE=$0 export BAKEFILE=$0
else else
if [[ -z "$BAKEFILE" ]]; then if [[ -z "$BAKEFILE" ]]; then
# BAKEFILE not set externally # BAKEFILE not set externally
for BAKEDEFAULT in Bakefile bakefile /dev/null; do for BAKEDEFAULT in Bakefile bakefile /dev/null; do
if [[ -f ./$BAKEDEFAULT ]]; then if [[ -f ./$BAKEDEFAULT ]]; then
BAKEFILE=./$BAKEDEFAULT export BAKEFILE=./$BAKEDEFAULT
break break
fi fi
done done