[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: BUG?: BASH_ENV as a target-specific variable is inherited by the tar
From: |
Cook, Malcolm |
Subject: |
RE: BUG?: BASH_ENV as a target-specific variable is inherited by the target's prerequisites even if marked "private" |
Date: |
Mon, 4 Dec 2023 20:30:12 +0000 |
> I now believe this to be a manifestation of [bug #61463: private does not
> suppress inheritance on exported target specific
> variables](https://savannah.gnu.org/bugs/index.php?61463)
> which I now discover has been fixed in [GNU Make 4.4.1
> released!](https://lists.gnu.org/archive/html/info-gnu/2023-
> 02/msg00011.html) with the following release note:
>
> * Previously target-specific variables would inherit their "export" capability
> from parent target-specific variables even if they were marked private. Now
> private parent target-specific variables have no affect. For more details
> see https://savannah.gnu.org/bugs/index.php?61463
>
> I will get the newest version installed and confirm...
FWIW: Until I do, in the meantime, I find the workaround for this bug provided
by @Paul Smith (thanks!) is workarounding for this case 😉
Viz:
----------------------
.SILENT:
.DEFAULT_GOAL:=test
.ONESHELL:
SHELL := /bin/bash
.PHONY test:
test:
@echo Running $@ of $(MAKEFILE_LIST) in a clean environment with
$$($(MAKE) --version | head -n 1)
env -i $(MAKE) -f $(MAKEFILE_LIST) -B myTarget
.PHONY: myTarget
myTarget: export private BASH_ENV=${p_BASH_ENV}
myTarget: private p_BASH_ENV:=desiredEnvironment.sh
# c.f. bug workaround
(https://lists.gnu.org/archive/html/help-make/2023-01/msg00006.html)
# I would expect that using the "private modifier" here would causes
# BASH_ENV to "not be inherited by prerequisites".
myTarget: itsPrerequisite desiredEnvironment.sh
echo Running recipe for: $@
echo BASH_ENV=$${BASH_ENV}
echo myVariable=$${myVariable}
.PHONY: itsPrerequisite
itsPrerequisite:
echo Running recipe for: $@
echo BASH_ENV=$${BASH_ENV}
echo myVariable=$${myVariable}
desiredEnvironment.sh:
echo Running recipe for: $@
printf 'echo sourcing $@\n' > $@
printf 'myVariable=myValue\n' >> $@
-------------------
With expected transcript:
$ make -f t.mk
Running test of t.mk in a clean environment with GNU Make 4.4
Running recipe for: itsPrerequisite
BASH_ENV=
myVariable=
Running recipe for: desiredEnvironment.sh
sourcing desiredEnvironment.sh
Running recipe for: myTarget
BASH_ENV=desiredEnvironment.sh
myVariable=myValue