[bug #67265] $(file) in commands is executed too early

Timothy N Murphy <[email protected]> Mon, 30 Jun 2025 11:29:12 -0400 (EDT)
Newsgroups gmane.comp.gnu.make.bugs
Message-ID <[email protected]>
Follow-up Comment #2, bug #67265 (group make):

Hi,

Make always expands a command before executing it in the shell - this is why
your $(file) is getting done before mkdir.

I don't think you need $(file) here at all since you can use the shell to
create a file with something like 

mkdir -p test.d
echo '$(contents)' > test.d/test.txt

You might have some trouble with newlines. In that case you could try:

contents:=hello world\n

all:
        mkdir -p test.d
        echo -e '$(contents)' > test.d/test.txt

.PHONY: all


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?67265>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaGKtSAAKCRCqLAuaBUf3
TlnJAP9n1QTSYT7fwp7KClnm5x7AS+mbLMnZ6k+qm4cIq84kFQEAuR64ox/JAOD4
VxkjOsfKZ+O6jS6pPXR0HNSPLl00ngw=
=blmI
-----END PGP SIGNATURE-----