/bin/sh: How to retain variables set in a while loop?

Jonathan I. Kamens jik at athena.mit.edu
Thu Mar 7 12:21:49 AEST 1991


In article <9209 at exodus.Eng.Sun.COM>, mcgrew at ichthous.Eng.Sun.COM (Darin McGrew) writes:
|> If the while loop has its stdio redirected in any way, it is put
|> in a subshell.  (Likewise with for loops, case statements, etc.)
|> The subshell has no way to pass variables back to its parent
|> shell.

  I just want to point out that this problem is eliminated in some newer
versions of the bourne shell, and also in some other shells (including, I
believe, bash and ksh) that use the bourne shell's language.

  Of course, the C shell gets around the problem by not allowing redirection
into loops at all :-).

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.shell mailing list