NetBSD Problem Report #49443

From www@NetBSD.org  Tue Dec  2 22:14:55 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7F980A5864
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  2 Dec 2014 22:14:55 +0000 (UTC)
Message-Id: <20141202221454.937B1A64EF@mollari.NetBSD.org>
Date: Tue,  2 Dec 2014 22:14:54 +0000 (UTC)
From: michipili@gmail.com
Reply-To: michipili@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Problem in make variable modifiers
X-Send-Pr-Version: www-1.0

>Number:         49443
>Category:       bin
>Synopsis:       Problem in make variable modifiers
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 02 22:15:00 +0000 2014
>Closed-Date:    Mon May 23 21:02:09 +0000 2022
>Last-Modified:  Mon May 23 21:02:09 +0000 2022
>Originator:     Michael Grünewald
>Release:        NetBSD 6.1.5
>Organization:
>Environment:
NetBSD culioda.celt.net 6.1.5 NetBSD 6.1.5 (GENERIC) amd64

>Description:
The variable modifier :[#] does not behave as documented in
the manual page when used in a Makefile.

Instead of resulting in a variable expanding into the number
of words in that variable (expected) the :[#] causes a syntax
error similar to:

    make: Unclosed substitution for TEST (] missing)

We may guess that the # appearing in the variable modifier
is erroneously interpreted as a comment character.

Quite intererstingly, the following one-liner behaves
appropriately:

    % make TEST='1 2 3' -V '${TEST:[#]}'
    3

>How-To-Repeat:
cat > reproduce.mk <<EOF
TEST=1 2 3
.warning ${TEST:[#]}
EOF

make -f reproduce.mk

>Fix:

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/49443: Problem in make variable modifiers
Date: Wed, 3 Dec 2014 10:52:14 +0100

 This works in -current.

 Martin

From: Michael <michipili@gmail.com>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/49443: Problem in make variable modifiers
Date: Wed, 03 Dec 2014 10:57:55 +0100

 Martin Husemann wrote:
 > Subject: Re: bin/49443: Problem in make variable modifiers
 >
 >  This works in -current.
 This is good news Martin!  Does it mean, it will work in NetBSD 6.1.6
 and 6.2?

From: Martin Husemann <martin@duskware.de>
To: Michael <michipili@gmail.com>
Cc: gnats-bugs@NetBSD.org, dh@NetBSD.org
Subject: Re: bin/49443: Problem in make variable modifiers
Date: Wed, 3 Dec 2014 11:05:58 +0100

 On Wed, Dec 03, 2014 at 10:57:55AM +0100, Michael wrote:
 > Martin Husemann wrote:
 > > Subject: Re: bin/49443: Problem in make variable modifiers
 > >
 > >  This works in -current.
 > This is good news Martin!  Does it mean, it will work in NetBSD 6.1.6
 > and 6.2?
 > 

 I don't think so, but it works in netbsd-7 as well (not very suprising).
 There have been serious changes since -6, not sure if this is easy to
 pullup. David, any ideas?

 Martin

From: Michael <michipili@gmail.com>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/49443: Problem in make variable modifiers
Date: Wed, 03 Dec 2014 11:12:22 +0100

 Martin Husemann wrote:
 > The following reply was made to PR bin/49443; it has been noted by GNATS.
 >
 >  I don't think so, but it works in netbsd-7 as well (not very suprising).
 >  There have been serious changes since -6 […]
 It is fine for me to wait for netbsd-7.  Thanks for your help!

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/49443: Problem in make variable modifiers
Date: Wed, 3 Dec 2014 17:22:51 +0000

 On Wed, Dec 03, 2014 at 10:10:02AM +0000, Martin Husemann wrote:
  > > >  This works in -current.
  > > This is good news Martin!  Does it mean, it will work in NetBSD 6.1.6
  > > and 6.2?
  >  
  >  I don't think so, but it works in netbsd-7 as well (not very suprising).
  >  There have been serious changes since -6, not sure if this is easy to
  >  pullup. David, any ideas?

 If you mean (me David), I haven't any idea - I don't remember anything
 that matches this bug, but the type of parser hacking that most likely
 fixed it is rarely a good pullup candidate.

 We could of course just sync -6's make with head, or with -7, if it
 doesn't cause build problems in base. (I don't think doing that with
 -5 would be safe though.)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->closed
State-Changed-By: rillig@NetBSD.org
State-Changed-When: Mon, 23 May 2022 21:02:09 +0000
State-Changed-Why:

Fixed in parse.c 1.181 from 2012.03.24.20.28.41, which fixes the special
case of '#' occurring in the modifier ':[#]'.

As stated above, all 6.x releases use revision 1.180 that still contains
the bug. Starting with 7.0, the bug fix was included in the releases.

Interestingly, many versions of make from the 1990s or 2000s run into an
endless loop when they are fed with the reproduce.mk from above.  I
didn't investigate the exact history of that since it is historical.

Thanks for the PR.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.