NetBSD Problem Report #51027

From kre@munnari.OZ.AU  Wed Mar 30 12:04:42 2016
Return-Path: <kre@munnari.OZ.AU>
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 "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B0FC77A46A
	for <gnats-bugs@www.NetBSD.org>; Wed, 30 Mar 2016 12:04:42 +0000 (UTC)
Message-Id: <201603301203.u2UC3m4b013612@andromeda.noi.kre.to>
Date: Wed, 30 Mar 2016 19:03:48 +0700 (ICT)
From: kre@munnari.OZ.AU
To: gnats-bugs@www.NetBSD.org
Subject: /bin/sh misparses $10 (etc)
X-Send-Pr-Version: 3.95

>Number:         51027
>Category:       bin
>Synopsis:       /bin/sh misparses $10 (etc)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 30 12:05:00 +0000 2016
>Closed-Date:    Sat Aug 27 23:12:44 +0000 2016
>Last-Modified:  Sat Aug 27 23:12:44 +0000 2016
>Originator:     Robert Elz
>Release:        NetBSD 7.99.26 (all to current as of date of this PR)
>Organization:
>Environment:
(irrelevant)


System: NetBSD andromeda.noi.kre.to 7.99.26 NetBSD 7.99.26 (VBOX64-1.1-20160128) #43: Thu Jan 28 16:09:08 ICT 2016 kre@onyx.coe.psu.ac.th:/usr/obj/current/kernels/amd64/VBOX64 amd64
Architecture: x86_64
Machine: amd64
>Description:
	The correct way to parse $10 is as ${1}0 but /bin/sh parses
	it the same as ${10}.  Other shells do not.

>How-To-Repeat:
	sh -c ' set -- a b c d e f g h i j k l m n o p
		echo ${1}0 ${10} $10 ... should be a0 j a0'

>Fix:
	This can be considered a placeholder PR, this bug is fixed
	in my sources already.   Fix coming to CVS soon.

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51027 CVS commit: src/bin/sh
Date: Thu, 31 Mar 2016 12:12:52 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Mar 31 16:12:52 UTC 2016

 Modified Files:
 	src/bin/sh: parser.c

 Log Message:
 PR bin/51027 - fix the parsing of references to shell parameters
 when given without braces (ie: $2 etc).  Only the first 9 shell
 parameters ($1 .. $9) and the special parameter ($0) can be
 referenced this way, $10 is ${1}0 not ${10}.   Make it so.
 This bug brought to notice by Sven Mascheck's web pages which
 discuss (among other things) the history of this (and other ash
 based) shells .. see http://www.in-ulm.de/~mascheck/ (from kre@)


 To generate a diff of this commit:
 cvs rdiff -u -r1.113 -r1.114 src/bin/sh/parser.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51027 CVS commit: src/tests/bin/sh
Date: Thu, 31 Mar 2016 12:21:10 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Mar 31 16:21:10 UTC 2016

 Modified Files:
 	src/tests/bin/sh: t_expand.sh

 Log Message:
 PR bin/51027 - tests for shell positional parameters, including
 testing that $10 is correctly parsed as ${1}0 and not as ${10}.
 More than that though. (from kre@)


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/tests/bin/sh/t_expand.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 11:24:08 +0000
State-Changed-Why:
christos worked on this, is it fixed?


From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/51027 (/bin/sh misparses $10 (etc))
Date: Mon, 04 Apr 2016 19:32:10 +0700

     Date:        Mon,  4 Apr 2016 11:24:09 +0000 (UTC)
     From:        wiz@NetBSD.org
     Message-ID:  <20160404112409.1B9697AA9C@mollari.NetBSD.org>

   | Synopsis: /bin/sh misparses $10 (etc)
   | christos worked on this, is it fixed?

 Yes, this is fixed.   However, this one (of all the recent changes to sh)
 should be pulled up to both NetBSD-6 and NetBSD-7 - it has been broken
 for 20+ years, and should finally get fixed everywhere.

 However, because of the other changes that have been made, the patch that
 fixed this problem will almost certainly not apply cleanly to the earlier
 versions.   The fix is identical though (it is just a half-line change), and
 if someone tells me what to do with it, I could easily supply a patch that
 would work on the older shell sources (or two, if that should happen to be
 needed - but I suspect probably not.)

 kre

State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 12:43:06 +0000
State-Changed-Why:
Confirmed fixed, thanks!


State-Changed-From-To: closed->pending-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 06 Aug 2016 11:48:37 +0000
State-Changed-Why:
Pullup requests submitted.
	[pullup-7 #1212]
	[pullup-6 #1397]


From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51027 CVS commit: [netbsd-6] src/bin/sh
Date: Sat, 27 Aug 2016 14:46:36 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Aug 27 14:46:36 UTC 2016

 Modified Files:
 	src/bin/sh [netbsd-6]: parser.c

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #1397):
 	bin/sh/parser.c: revision 1.114 via patch
 PR bin/51027 - fix the parsing of references to shell parameters
 when given without braces (ie: $2 etc).  Only the first 9 shell
 parameters ($1 .. $9) and the special parameter ($0) can be
 referenced this way, $10 is ${1}0 not ${10}.   Make it so.
 This bug brought to notice by Sven Mascheck's web pages which
 discuss (among other things) the history of this (and other ash
 based) shells .. see http://www.in-ulm.de/~mascheck/ (from kre@)


 To generate a diff of this commit:
 cvs rdiff -u -r1.80 -r1.80.4.1 src/bin/sh/parser.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51027 CVS commit: [netbsd-7] src/bin/sh
Date: Sat, 27 Aug 2016 15:20:49 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Sat Aug 27 15:20:49 UTC 2016

 Modified Files:
 	src/bin/sh [netbsd-7]: parser.c

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #1212):
 	bin/sh/parser.c: revision 1.114 via patch
 PR bin/51027 - fix the parsing of references to shell parameters
 when given without braces (ie: $2 etc).  Only the first 9 shell
 parameters ($1 .. $9) and the special parameter ($0) can be
 referenced this way, $10 is ${1}0 not ${10}.   Make it so.
 This bug brought to notice by Sven Mascheck's web pages which
 discuss (among other things) the history of this (and other ash
 based) shells .. see http://www.in-ulm.de/~mascheck/ (from kre@)


 To generate a diff of this commit:
 cvs rdiff -u -r1.90 -r1.90.4.1 src/bin/sh/parser.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 27 Aug 2016 23:12:44 +0000
State-Changed-Why:
Pullups completed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.