View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001549 | 1003.1(2016/18)/Issue7+TC2 | Shell and Utilities | public | 2022-01-13 16:18 | 2024-06-11 09:07 |
Reporter | dmitry_goncharov | Assigned To | |||
Priority | normal | Severity | Editorial | Type | Clarification Requested |
Status | Closed | Resolution | Accepted As Marked | ||
Name | Dmitry Goncharov | ||||
Organization | |||||
User Reference | |||||
Section | Makefile Syntax | ||||
Page Number | 2973 | ||||
Line Number | 98627 | ||||
Interp Status | Approved | ||||
Final Accepted Text | 0001549:0005754 | ||||
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 .POSIX: M=word N=${M:word=a\ b} all:; echo ${N} ${M:word=a\ b} 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\ 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." | ||||
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 | tc3-2008 |
|
This is not a problem with the HTML translation, so I have moved it to the Issue7+TC2 project. |
|
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\ b} Not sure if that's intentional. If it is (which would allow the Solaris behaviour), it would be better to make it explicit. |
|
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). |
|
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. .POSIX: M=word N=${M:word=a\ b} K=a\ b all: ; echo ${N} ${K} all: ; echo 'a\ b' all: ; echo 'a\ b' all: ; echo 'a\ b' |
|
Interpretation response ------------------------ The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor. Rationale: ------------- None. Notes to the Editor (not part of this interpretation): ------------------------------------------------------- Change: When an escaped <newline> (one preceded by a <backslash>) is found anywhere in the makefile except in a command line, an include line, or a line immediately preceding an include line, it shall be replaced, along with any leading white space on the following line, with a single <space>. 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>.to: When an escaped <newline> (one preceded by a <backslash>) is found anywhere in the makefile except in a command line after macro expansion, an include line, or a line immediately preceding an include line, it shall be replaced, along with any leading white space on the following line, with a single <space>. After all macro expansion is complete, when an escaped <newline> is found in a command line in a makefile, the command line that is executed 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>. |
|
Interpretation proposed: 25 March 2022 |
|
Interpretation Approved: 26 April 2022 |
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 | => https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html |
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 | |
2022-03-17 16:14 | geoffclare | Note Added: 0005754 | |
2022-03-17 16:15 | geoffclare | Interp Status | --- => Pending |
2022-03-17 16:15 | geoffclare | Final Accepted Text | => 0001549:0005754 |
2022-03-17 16:15 | geoffclare | Status | New => Interpretation Required |
2022-03-17 16:15 | geoffclare | Resolution | Open => Accepted As Marked |
2022-03-17 16:15 | geoffclare | Tag Attached: tc3-2008 | |
2022-03-25 17:08 | agadmin | Interp Status | Pending => Proposed |
2022-03-25 17:08 | agadmin | Note Added: 0005763 | |
2022-04-26 12:02 | agadmin | Interp Status | Proposed => Approved |
2022-04-26 12:02 | agadmin | Note Added: 0005822 | |
2022-05-19 08:39 | geoffclare | Status | Interpretation Required => Applied |
2024-06-11 09:07 | agadmin | Status | Applied => Closed |