make-alpha
[Top][All Lists]
Advanced

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

newline escape problem.


From: Paul Smith
Subject: newline escape problem.
Date: Mon, 28 Oct 2002 19:37:00 -0500

Ref https://savannah.gnu.org/bugs/?func=detailbug&group_id=71&bug_id=1332

I'm working on a fix for this bug.  According to POSIX, make should
invoke the subshell with the backslash-newline pair intact, and only
remove a leading TAB if it exists.

While fixing this bug I ran into a strange situation.  The make code
works like this, in the case of the "slow path" (invoke a shell):

  * Construct a string with all the "special characters" escaped with
    backslashes.

  * Prefix the string with "$(SHELL) -c "

  * Recursively call ourself to parse the string up into an argv array.

So, if you have a makefile like this:

  all: ; :; echo 'hi\
   there'

then make sees it can't use the "fast path" due to the semicolon.  It
constructs a string like this:

  /bin/sh -c echo\ \'hi\
  \ there\'

(note how the backslash and newline are not escaped, but everything else
is.)  Then it calls itself again to parse that.  The second time around
the fast path is used since everything is quoted, but the
backslash/newline is also removed: these two commands are _not_
identical because the unquoted version would resolve to:

  echo 'hi\
   there'

and the quoted one resolves to:

  echo 'hi there'


My question is, can anyone think of a good reason for the "slow path" to
behave like this?  I don't understand why it doesn't just parse the
$(SHELL) into arguments, then add on a "-c" argument and the original
string that was in the makefile command (sans TABs where appropriate of
course) as one argument...

Does anyone know of a good reason not to do this?

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden> HASMAT: HA Software Mthds & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.




reply via email to

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