NetBSD Problem Report #42829

From www@NetBSD.org  Tue Feb 16 18:38:30 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 3FAD663B8DE
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 16 Feb 2010 18:38:30 +0000 (UTC)
Message-Id: <20100216183830.0D2C563B11D@www.NetBSD.org>
Date: Tue, 16 Feb 2010 18:38:30 +0000 (UTC)
From: rhansen@bbn.com
Reply-To: rhansen@bbn.com
To: gnats-bugs@NetBSD.org
Subject: Almquist shell does not perform parameter expansion on ${ENV}
X-Send-Pr-Version: www-1.0

>Number:         42829
>Category:       standards
>Synopsis:       Almquist shell does not perform parameter expansion on ${ENV}
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 16 18:40:00 +0000 2010
>Closed-Date:    Sat Dec 29 02:49:14 +0000 2018
>Last-Modified:  Sat Dec 29 02:49:14 +0000 2018
>Originator:     Richard Hansen
>Release:        5.0
>Organization:
>Environment:
NetBSD deer-netbsd.bbn.com 5.0_STABLE NetBSD 5.0_STABLE (GENERIC) #4: Tue Feb  2 10:43:58 EST 2010  gdt@fnord.ir.bbn.com:/n0/obj/gdt-5/amd64/sys/arch/amd64/compile/GENERIC amd64
>Description:
NetBSD 5.0's /bin/sh does not perform parameter expansion on the contents of the ENV environment variable before using it as a pathname to a file.  POSIX:2004 [1] and POSIX:2008 [2] (at least) require parameter expansion.

Also see PR #40639 [3], which is the same bug except applied to ${PS1} instead of ${ENV}.

[1] <http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_03>
[2] <http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_03>
[3] <http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40639>
>How-To-Repeat:
$ echo "echo foo" > foo
$ ENV="${PWD}/foo" /bin/sh -i
foo
$ exit
$ ENV='${PWD}/foo' /bin/sh -i
$ exit
$ 

Notice that "foo" is not printed when ${PWD}/foo is enclosed in single quotes.
>Fix:

>Release-Note:

>Audit-Trail:
From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42829 CVS commit: src/bin/sh
Date: Tue, 11 Dec 2018 13:31:21 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Tue Dec 11 13:31:20 UTC 2018

 Modified Files:
 	src/bin/sh: main.c parser.c parser.h sh.1

 Log Message:
 PR standards/42829

 Implement parameter and arithmetic expansion of $ENV
 before using it as the name of a file from which to
 read startup commands for the shell.   This continues
 to happen for all interactive shells, and non-interactive
 shells for which the posix option is not set (-o posix).

 On any actual error, or if an attempt is made to use
 command substitution, then the value of ENV is used
 unchanged as the file name.

 The expansion complies with POSIX XCU 2.5.3, though that
 only requires parameter expansion - arithmetic expansion
 is an extension (but for us, it is much easier to do, than
 not to do, and it allows some weird stuff, if you're so
 inclined....)   Note that there is no ~ expansion (use $HOME).


 To generate a diff of this commit:
 cvs rdiff -u -r1.78 -r1.79 src/bin/sh/main.c
 cvs rdiff -u -r1.158 -r1.159 src/bin/sh/parser.c
 cvs rdiff -u -r1.26 -r1.27 src/bin/sh/parser.h
 cvs rdiff -u -r1.211 -r1.212 src/bin/sh/sh.1

 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: kre@NetBSD.org
State-Changed-When: Tue, 11 Dec 2018 15:16:12 +0000
State-Changed-Why:
The shell in NetBSD HEAD now expands ENV (parameter and
arithmetic expansion) before using it.

Is that all that is needed for this PR ?


State-Changed-From-To: feedback->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 29 Dec 2018 02:49:14 +0000
State-Changed-Why:
This is believed to be fixed, and request for feedback failed
(submitter's original address no longer works).


>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.