why doesn't this shell program work

Dennis Smith quenton at ecr.UUCP
Tue Mar 5 19:42:32 AEST 1985


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.



More information about the Comp.unix mailing list