Date: Tue, 13 Jul 1999 20:15:17 +0200 (CEST) From: Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de> To: freebsd-hackers@FreeBSD.ORG Subject: Re: bin/12578: `` subshell taints PWD Message-ID: <199907131815.UAA12928@dorifer.heim3.tu-clausthal.de>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907131815.UAA12928>