Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!genrad!mit-eddie!godot!ima!johnl From: johnl@ima.UUCP Newsgroups: net.unix-wizards Subject: Re: Re(2): shell bug I reported here a f Message-ID: <508@ima.UUCP> Date: Mon, 11-Mar-85 23:44:32 EST Article-I.D.: ima.508 Posted: Mon Mar 11 23:44:32 1985 Date-Received: Thu, 14-Mar-85 04:04:42 EST Lines: 23 Nf-ID: #R:callan:-31400:ima:19800006:000:955 Nf-From: ima!johnl Mar 10 23:55:00 1985 > if true > then > parent > parent > parent > fi < /dev/null > > shows the first two 'parent' commands are run from a subshell, while the > third is run from the main shell! What IS going on? Glad you asked. In fact, all three of the "parent" programs are run from a subshell. There is, however, a longstanding hack in the shell such that the lexically last command in a subshell is exec'ed directly without an extra fork, which saves a little time. This is what you're seeing. All this goes to show that although the shell is a thing of wonder, its semantics are not well specified. (The C Shell is even worse, lest people think I'm biased.) The semantics I'd like to see would promise that all variable setting be (effectively) in the top shell unless explicitly put in a subshell by enclosing a sequence in parens. I realize this would be tricky to implement, but it sure would make shell programming easier. John Levine, ima!johnl