bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: escaped newline in macro expansion in command line


From: Dmitry Goncharov
Subject: Re: escaped newline in macro expansion in command line
Date: Fri, 7 Jan 2022 11:32:03 -0500

On Fri, Dec 24, 2021 at 6:30 PM Humm <hummsmith42@gmail.com> wrote:
> That’s the argument I’m making.

Humm, in the following example do you want N and M to expand to
different values? If yes, can you please tell us about your use case
where such behavior is needed?

.POSIX:
M=word
N=${M:word=a\
b}
all:; echo ${N} ${M:word=a\
b}

i tested gmake, bmake, sun make and aix make.
gmake and bmake both replace the newline with a space and pass 'a b a
b' to the shell.
sun make fails to find the closing brace and exits with an error message.
aix make removes the newline and passes 'a b ab' to the shell.

in the following example
all:; echo 'a\
b'
gmake and sun make both pass 'a\
b' to the shell.
bmake passes 'a b' to the shell.
aix make passes 'ab' to the shell.

i think gnu make's behavior is correct. Otherwise, variable expansion
becomes context dependent and who needs that complication?
Gnu make manual is quite explicit
5.1.2 says
"Variable and function references in recipes have identical syntax and
semantics to references elsewhere in the makefile."

If we can agree, then i'll file a request to opengroup to explicitly
state that this

"When an escaped <newline> is found in a command line in a makefile,
the command line shall contain the <backslash>, the <newline>, and the
next line, except that the first character of the next line shall not
be included if it is a <tab>".

takes place after variable expansion.

regards, Dmitry



reply via email to

[Prev in Thread] Current Thread [Next in Thread]