On Fri, 2021-12-24 at 10:45 +0000, Humm wrote: > Consider the Makefile: > > .POSIX: > M = word > all: > echo ${M:word=a\ > b} > > I believe, as the escaped newline is in a command line, the expected > behavior is to let the macro expand to it, and thus to run the > command > > echo a\ > b > > with output `ab`. The actual output is `a b`.
I understand what you're saying, but it's not true that the expected behavior is to run the command: echo a\ b In your example the backslash is part of a variable expansion: it's INSIDE the variable expansion so it will be handled by make as part of expanding the variable and won't ever be passed to the shell. It's handled as if you wrote: M = word _X = ${M:word=a\ b all: ; echo ${_X} Where you would expect to see "a b". There is an argument to be made that the backslash should be managed as if it were part of a command line and not part of a variable assignment because it appears in a recipe, even though it's part of a make variable expansion. If the backslash were handled that way then make would see this: echo ${M:word=ab} after the backslash/newline was removed and it would run the command: echo ab which is still not echo a\ b but would give equivalent output in this case. I don't know offhand what the right behavior is. No version of make I've been able to find actually works this latter way, removing the backslash first.