bugmake - Bugs: bug #35135, $() constructs that span multiple...

 
 

bug #35135: $() constructs that span multiple lines may add un-intended newlines

Submitted by:  None
Submitted on:  Tue 20 Dec 2011 10:28:41 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 3.82Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 20 Dec 2011 11:50:06 PM UTC, comment #1:

This is expected behavior. One of the most important features of define/endef is that newlines are preserved. It's the only way to get newlines into variable values, which is important in conjunction with $(eval ...) among other places.

If you want to embed newlines in the define but not have them in the result, you must use backslashes to escape them; this works as expected:

Paul D. Smith <psmith>
Project Administrator
Tue 20 Dec 2011 10:28:41 PM UTC, original submission:

Example:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
define SOME_MACRO =
$(if ${SOMETHING}
, RESULT1
, RESULT2
)
endef

%.o : %.cc
${CC} ${FLAGS} ${SOME_MACRO} ${MORE_FLAGS} ${<} -o ${@}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In 3.81 this won't work at all -- $(if ...) statements won't span multiple lines correctly in that version. In 3.82, it parses correctly but inserts newlines. The net behavior is ${CC} gets executed with ${FLAGS}, and may or may not include either RESULT1 or RESULT2, but ${MORE_FLAGS} and everything past it gets executed separately within the sub-shell.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by psmith (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 20 Dec 2011 11:50:06 PM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1