Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site ecr.UUCP
Path: utzoo!hcrvax!ecrhub!ecr!quenton
From: quenton@ecr.UUCP (Dennis Smith)
Newsgroups: net.unix
Subject: Re: why doesn't this shell program work
Message-ID: <115@ecr.UUCP>
Date: Tue, 5-Mar-85 04:42:32 EST
Article-I.D.: ecr.115
Posted: Tue Mar  5 04:42:32 1985
Date-Received: Thu, 7-Mar-85 08:07:35 EST
References: <2147@drutx.UUCP>
Organization: Emerald City Research Inc., Toronto
Lines: 12

The shell file in question piped a "for" loop into "pr".  Inside the
"for" loop, a shell variable was set.  The question was - why is the
variable not set after the "for .. | pr" is over?

One must recognize when the shell, in its perverted manner, fires up
new processes or forked copies of itself to do things.  In this case,
the shell has obviously forked a copy of itself to handle the "for",
because it is piped.  Thus the variable set inside the for was
actually set (and lost) in another shell process.

It would seem that sh does not really have to do this unless the
whole mess was followed by &, but it seems to.