Subject: bin/29985: make(1) interprets backslash wrongly
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <roland.illig@gmx.de>
List: netbsd-bugs
Date: 04/15/2005 23:41:00
>Number:         29985
>Category:       bin
>Synopsis:       make(1) interprets backslash wrongly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 15 23:41:00 +0000 2005
>Originator:     roland.illig@gmx.de
>Release:        NetBSD 2.99.15
>Organization:
	
>Environment:
	
	
System: NetBSD baccf5ee.roland-illig.de 2.99.15 NetBSD 2.99.15 (GENERIC) #0: Wed Feb 9 20:19:30 CET 2005 build@baccf5ee.roland-illig.de:/home/build/objroot/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
Userland: NetBSD-1.6.2
>Description:

	The NetBSD-1.6.2 make(1), the current pkgsrc bmake, and the
	NetBSD-2.99.15 make(1) all handle backspace characters as line-
	continuations when they appear as substitutions at the end of a
	line inside a .for loop.

	The documentation does not mention how backspace characters are
	interpreted except in a few special cases. I expect that back-
	space characters are only handled specially when they appear as
	tokens in a Makefile, not as values of a variable substitution.

	The appended code sample demonstrates that the backslash in a:\
	is properly quoted by the :Q operator, but after that is inter-
	preted as a backslash character that concatenates the two `echo'
	lines.

	Actually I'm not sure how to fix this. At least the documenta-
	tion of make(1) should mention this behaviour, as it is unex-
	pected.

>How-To-Repeat:

	A=	a:\ a:\file.txt
	all:
	.for a in ${A}
		echo ${a:Q}
		echo "<"${a:Q}">"
	.endfor

>Fix:

	Make(1) should process Makefiles in the following order:

	1. read in a logical line
	2. Do variable substitutions
	3. append the substituted line

	The code in src/usr.bin/make/for.c, lines 371..375 seems to be
	responsible for this behaviour.

>Unformatted: