Subject: bin/33866: make(1) does not :Q the newline character correctly
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <rillig@NetBSD.org>
List: netbsd-bugs
Date: 06/29/2006 15:15:00
>Number: 33866
>Category: bin
>Synopsis: make(1) does not :Q the newline character correctly
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 29 15:15:00 +0000 2006
>Originator: Roland Illig
>Release: NetBSD 3.0_STABLE
>Organization:
>Environment:
System: NetBSD baccf5ee.roland-illig.de 3.0_STABLE NetBSD 3.0_STABLE (GENERIC) #0: Sat Jun 17 13:16:17 CEST 2006 build@baccf5ee.roland-illig.de:/home/build/3/2006-06/i386/work/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
The make(1) man page says that the :Q operator escapes all shell
metacharacters properly. However, for the newline character this is
wrong. It is converted into <backslash><newline>, which does not result
in a single newline character when parsed by the shell.
>How-To-Repeat:
cd pkgsrc/regress/make-quoting && make REGRESS_TESTS=newline
>Fix:
Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.110
diff -u -p -r1.110 var.c
--- var.c 19 May 2006 17:29:01 -0000 1.110
+++ var.c 29 Jun 2006 14:05:45 -0000
@@ -1838,9 +1838,15 @@ VarQuote(char *str)
buf = Buf_Init(MAKE_BSIZE);
for (; *str; str++) {
- if (strchr(meta, *str) != NULL)
- Buf_AddByte(buf, (Byte)'\\');
- Buf_AddByte(buf, (Byte)*str);
+ if (*str == '\n') {
+ Buf_AddByte(buf, (Byte)'"');
+ Buf_AddByte(buf, (Byte)'\n');
+ Buf_AddByte(buf, (Byte)'"');
+ } else {
+ if (strchr(meta, *str) != NULL)
+ Buf_AddByte(buf, (Byte)'\\');
+ Buf_AddByte(buf, (Byte)*str);
+ }
}
Buf_AddByte(buf, (Byte)'\0');
str = (char *)Buf_GetAll(buf, NULL);
>Unformatted: