On Thu, 2025-05-29 at 09:43 +0200, Renaud Pacalet wrote: > I recently observed a strange `patsubst` behavior when substituting > the empty string: > > ``` > $ cat Makefile > > .PHONY: all > all:; > $(info $(patsubst %.,,1.2)) > > $ make > 1.2 > make: Nothing to be done for 'all'. > ``` > > I read the manual twice but I cannot explain this behavior. What did > I miss?
When using patsubst the pattern must match the _entire_ word. If the pattern doesn't match the word, then the word is not changed. Here, "%." does not match the word "1.2". It would work if you used "%.2" as the pattern, like: $ echo '$(info $(patsubst %.2,2,1.2))' | make -f- 2 make: *** No targets. Stop. If it were possible to have multiple match characters then you could do something like "%.%" but that is not possible. Without knowing what you're actually trying to do, I can't suggest an alternative that might work for you.