NetBSD Problem Report #53756

From rillig@nb7.fritz.box  Sat Dec  1 07:49:05 2018
Return-Path: <rillig@nb7.fritz.box>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E62087A19B
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  1 Dec 2018 07:49:05 +0000 (UTC)
Message-Id: <20181130194011.EEB5916D1CF@nb7.fritz.box>
Date: Fri, 30 Nov 2018 19:40:11 +0000 (UTC)
From: rillig@NetBSD.org
Reply-To: rillig@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: /bin/sh strips too many characters with %% modifier
X-Send-Pr-Version: 3.95

>Number:         53756
>Category:       bin
>Synopsis:       /bin/sh strips too many characters with %% modifier
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 01 07:50:00 +0000 2018
>Closed-Date:    Sat Dec 01 08:27:22 +0000 2018
>Last-Modified:  Sat Dec 01 08:27:22 +0000 2018
>Originator:     rillig@NetBSD.org
>Release:        NetBSD 7.0.2
>Organization:

>Environment:


System: NetBSD nb7.fritz.box 7.0.2 NetBSD 7.0.2 (GENERIC.201610210724Z) amd64
Architecture: x86_64
Machine: amd64
>Description:

line="// line comment /* block comment */"
printf '<%s>\n' "${line%%/\**}"

The %% should remove the longest suffix after "/*", since the first
asterisk is escaped. Bash and Ksh do it as expected, NetBSD's /bin/sh
doesn't. It removes everything after the first "/", whether or not that
is followed by a "*".

>How-To-Repeat:

>Fix:

Unknown
>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: leot@NetBSD.org
State-Changed-When: Sat, 01 Dec 2018 08:27:22 +0000
State-Changed-Why:
Duplicate of PR bin/53754.

(The reproduction test case is different for the
`line' initialization but the behaviour of sh(1)
is the same, i.e. with -current sh(1):

 <// line comment >

Roland, feel free to reopen it or bin/53754 if
this is not the case!)


Thank you!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.