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:o...@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message