help-make
[Top][All Lists]
Advanced

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

Re: whitespace


From: Paul Smith
Subject: Re: whitespace
Date: Tue, 14 Dec 2010 01:40:53 -0500

On Tue, 2010-12-14 at 08:22 +0330, ali hagigat wrote:
> var1='rrrr\
>         ffff'
> 
> ----------------------------------------
> 5.1.1 Splitting Recipe Lines
> In this situation the newline quoting rules for makefiles will be
> used, and the backslash-newline will be removed.
> ----------------------------------------
> make not only removes backslash-newline for echo $(var1)
> but also white spaces!

That backslash is in a variable assignment, not in a recipe, so the part
of the manual you quoted does not apply; the handling of backslashes in
variable assignments is different.

You're right that this is not well-defined in the GNU make manual, but
GNU make adheres to the POSIX spec for make which says:

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

So in your example, when var1 (which does not meet the exceptions) is
set it follows the rule that the backslash along with any leading
whitespace on the following line is replaced with a single space.  So
the value of var1 becomes, as you saw, "'rrrr ffff'"

This behavior should be made more clear in the GNU make manual.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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