Austin Group Defect Tracker

Aardvark Mark IV

Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001549 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Editorial Clarification Requested 2022-01-13 16:18 2022-01-14 20:31
Reporter dmitry_goncharov View Status public  
Assigned To
Priority normal Resolution Open  
Status New  
Name Dmitry Goncharov
User Reference
Section Makefile Syntax
Page Number 2973
Line Number 98627
Interp Status ---
Final Accepted Text
Summary 0001549: Escaped newline in macro expansion in command line.
Description Section "Makefile Syntax" says

"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..."

Consider the following example

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

Does posix require that in this example N and M expand to different values?

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\
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."
Desired Action Modify the text quoted above like this

"After all macro expansion is complete, 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>".
Tags No tags attached.
Attached Files

- Relationships

-  Notes
geoffclare (manager)
2022-01-14 09:47

This is not a problem with the HTML translation, so I have moved it to the Issue7+TC2 project.
geoffclare (manager)
2022-01-14 09:53

The proposed change would leave it implicitly unspecified what happens to <backslash><newline> in a macro expansion in a command line, such as for the second expansion in the example command line given:

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

Not sure if that's intentional. If it is (which would allow the Solaris behaviour), it would be better to make it explicit.
psmith (developer)
2022-01-14 14:14

I don't think it's intended to be left unspecified. I think the intent is that all macros are expanded using macro expansion rules (which do define how a backslash-newline pair should be handled), then any remaining backslash-newlines are handled as described for command lines (which, unfortunately, is different).
dmitry_goncharov (reporter)
2022-01-14 20:31

i believe everybody benefits if posix specifies explicitly that the required processing of an escaped newline in a recipe takes place after macro expansion. i'd like to stress again that the main benefit is that, this allows context independ macro expansion.

i thought the proposed change was explicit enough. But apparently it is not. If you can propose a better wording, that will be good.

i suspect, that sun make's behavior is not intentional, but rather a bug. Sun make handles various other cases like the following as required by posix.


all: ; echo ${N} ${K}

all: ; echo 'a\

all: ; echo 'a\

all: ; echo 'a\

- Issue History
Date Modified Username Field Change
2022-01-13 16:18 dmitry_goncharov New Issue
2022-01-13 16:18 dmitry_goncharov Name => Dmitry Goncharov
2022-01-13 16:18 dmitry_goncharov URL => [^]
2022-01-13 16:18 dmitry_goncharov Section => Makefile Syntax
2022-01-14 09:46 geoffclare Project Online Pubs => 1003.1(2016/18)/Issue7+TC2
2022-01-14 09:47 geoffclare Page Number => 2973
2022-01-14 09:47 geoffclare Line Number => 98627
2022-01-14 09:47 geoffclare Interp Status => ---
2022-01-14 09:47 geoffclare Note Added: 0005604
2022-01-14 09:53 geoffclare Note Added: 0005605
2022-01-14 14:14 psmith Note Added: 0005606
2022-01-14 20:31 dmitry_goncharov Note Added: 0005609

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker