URL: <https://savannah.gnu.org/bugs/?67265>
Summary: $(file) in commands is executed too early Group: make Submitter: zackw Submitted: Mon 30 Jun 2025 02:50:00 PM GMT Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: None Operating System: None Fixed Release: None Triage Status: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Mon 30 Jun 2025 02:50:00 PM GMT By: Zack Weinberg <zackw> This Makefile should, but does not, create a file named 'test.txt' in a directory named 'test.d': define contents hello world endef all: mkdir -p test.d $(file > test.d/test.txt, $(contents)) .PHONY: all Instead, you get an error message: Makefile:7: *** open: test.d/test.txt: No such file or directory. Stop. Evidently the $(file) special command has been executed out of sequence, before the mkdir command -- I'm guessing that, despite having the form of a command, it's being executed as part of variable expansion for the entire command list, before anything else happens. This is surprising and unlikely to be the desired behavior. Instead it should be executed only after all preceding commands have executed -- after the mkdir, in this case. The test makefile obviously could have been written more reliably with separate rules to create the directory and the file, with the latter depending on the former, but this is not possible in more complicated situations, and also, as you know, there are problems with having a directory as a prerequisite. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?67265> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature