From bfac4aadc6287f92b4248062428dc41d43af181b Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Wed, 23 Aug 2023 11:08:10 +0300 Subject: [PATCH] allow running naked --- README.md | 3 +++ bake | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9218382..303e776 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ _subcommand() { echo foo # NOTE: Bakefile gets sourced when read! somevar=value +if [ -z "$BAKEFILE" ]; then + echo This part is run if the file is sourced and not run in Bake +fi ``` diff --git a/bake b/bake index 9d28f41..a410e07 100755 --- a/bake +++ b/bake @@ -1,5 +1,5 @@ #!/bin/bash -## VERSION 22.6.10 +## VERSION 23.8.23 ## BASH-MAKE ========================================================== ## Utility to mimick some of GNU Make behavior, but run in a single ## 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 STANDALONE=${STANDALONE:-false} if [[ $STANDALONE = true ]]; then - BAKEFILE=$0 + export BAKEFILE=$0 else if [[ -z "$BAKEFILE" ]]; then # BAKEFILE not set externally for BAKEDEFAULT in Bakefile bakefile /dev/null; do if [[ -f ./$BAKEDEFAULT ]]; then - BAKEFILE=./$BAKEDEFAULT + export BAKEFILE=./$BAKEDEFAULT break fi done