From owner-freebsd-hackers Tue Jul 13 11:15:33 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dorifer.heim3.tu-clausthal.de (dorifer.heim3.tu-clausthal.de [139.174.243.252]) by hub.freebsd.org (Postfix) with ESMTP id 481BA14E1B for ; Tue, 13 Jul 1999 11:15:27 -0700 (PDT) (envelope-from olli@dorifer.heim3.tu-clausthal.de) Received: (from olli@localhost) by dorifer.heim3.tu-clausthal.de (8.8.8/8.8.8) id UAA12928 for freebsd-hackers@FreeBSD.ORG; Tue, 13 Jul 1999 20:15:17 +0200 (CEST) (envelope-from olli) Date: Tue, 13 Jul 1999 20:15:17 +0200 (CEST) From: Oliver Fromme Message-Id: <199907131815.UAA12928@dorifer.heim3.tu-clausthal.de> To: freebsd-hackers@FreeBSD.ORG Subject: Re: bin/12578: `` subshell taints PWD Organization: Administration Heim 3 Reply-To: freebsd-hackers@FreeBSD.ORG MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: TIN [version 1.2 RZTUC(3) PL2] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Sheldon Hearn wrote in list.freebsd-hackers: > On Tue, 13 Jul 1999 18:13:42 +0200, Oliver Fromme wrote: > > > Command substitution certainly has to spawn a subshell, even > > for built-in commands, because otherwise you could modify > > parent shell variables within command substitutions. > > But isn't that exactly what's happening here, where PWD is being tainted > by the commands evaluated within the substitution? Yes, I'd call that a bug which should be fixed. The manpage clearly says: "The shell expands the command substitution by executing command in a subshell environment and replacing the command substitution with the standard output of the command [...]" Alternatively, the manpage could be "fixed". ;-) I'm not sure if XPG4v2 requires command substitution to behave like that. At least, both Solaris' and DEC UNIX... oops... True64 UNIX do execute all command substitutions in a subshell (`pwd` does not affect the surrounding shell), and both claim XPG4 compliance. Therefore I think the right thing to do is to fix FreeBSD's sh to always execute command substitutions in a subshell. Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message