help-make
[Top][All Lists]
Advanced

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

Re: Need detail: backslash-newline sequences inside of single-quoted str


From: gk
Subject: Re: Need detail: backslash-newline sequences inside of single-quoted strings
Date: Sat, 25 Feb 2006 06:21:56 -0800

At 01:10 PM 2/24/2006, Paul D. Smith wrote:
Yes, that documentation was reworked and moved.  I'll update the NEWS
file.

Look in the chapter "Writing the Commands in Rules", section "Command
Syntax", sub-section "Splitting Command Lines".

Thanks.
I think the examples are a bit hard to follow (at least in how 'info' formats it) - confused somewhat by the fact that the example itself is indented from normal flow of paragraph text.

I hope my email preserves enough white space to illustrate what I'm trying to say: I have replace tabs with spaces here, just to be clear - use 'info make' to see exactly what I'm referring to.

The general rule says:

>If the first character of the next line after the
backslash-newline is a tab, then that tab (and only that tab) is
removed.
...

THE FIRST EXAMPLE IS VERY CLEAR

-- EXAMPLE1 START --
   For example, this makefile:

     all :
             @echo no\
     space
             @echo no\
             space
[...]
consists of four separate shell commands where the output is:

     nospace
     nospace
[...]

-- EXAMPLE1 END--

THE ABOVE EXAMPLE ESTABLISHES THESE CONVENTIONS:
1. The position of 'all :' defines the limit of the 'pseudo left margin' / terminal output of the example (5 spaces from left of the true document margin) 2. A tab is represented by 8 SPACES: horizontal distance from 'all' to indented next line, '@echo' 3. The 'pseudo left margin' of example output is in line with the vertical position established by 'all :'


THIS EXAMPLE IS A BIT HARD TO FOLLOW

-- EXAMPLE2 START --
As a more complex example, this makefile:

     all : ; @echo 'hello \
             world' ; echo "hello \
         world"

will run one shell with a command script of:

     echo 'hello \
     world' ; echo "hello \
         world"
-- EXAMPLE2 INTERRUPTED--

MY COMMENT:

This seems fine to here - though a bit obscure: I hope readers will be able to infer the difference between 8 SPACES representing a TAB (removed by make) and 4 spaces (preserved by make) as representing 4 SPACES (4 spaces is a common TAB length too).

It might be helpful to make note of these conventions at the start of the discussion.

-- EXAMPLE2 CONTINUED--

which, according to shell quoting rules, will yield the following
output:

     hello \
     world
     hello     world

Notice how the backslash/newline pair was removed inside the string
quoted with double quotes (`"..."'), but not from the string quoted
with single quotes (`'...'').  This is the way the default shell
[...]
-- EXAMPLE2 END--

I think it would help to make note of my observations by re-wording the final paragraph to more clearly emphasize how the original rule was interpreted by make - how the shell translates the interpreted rule into output is less important to explain since most users will understand this.

SUGGESTED REVISION:

Notice what happened:

1. the backslash/newline pair inside the string with single quotes was preserved by make and preserved by the shell, in final output 2. the tab character at the beginning of the second line of the string inside single quotes was removed by make (as always), since it immediately follows a backslash/newline pair 3. the backslash/newline pair inside the string with double quotes was preserved by make but interpreted as an escape sequence by the shell, in final output 4. the 4 spaces at the beginning of the second line of the string inside double quotes was preserved by make and preserved by the shell, in final output


- Greg Keraunen
http://www.xmake.org




reply via email to

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