[EMAIL PROTECTED] (Michael O'Donnell) writes:

> >it has a subtle scoping gotcha that drove me nuts the
> >first time I tripped over it - anybody know what I'm
> >referring to?
> 
> No?  Then how about this?
> 
>    result=badness    # init with failure default
>    spewSomeKindOfOutput | while read input
>    do
>        result=goodness
>    done
>    echo $result
> 
> What is the output?

In general, the inner part of the loop is run in a sub-shell.  This is
often transparent, but if you have an expression that has
side-effects, these effects blip out of existance when the sub-shell
disappears.

Regards,

--kevin
-- 
Kevin D. Clark (CetaceanNetworks.com!kclark)  |
Cetacean Networks, Inc.                       |   Give me a decent UNIX
Portsmouth, N.H. (USA)                        |  and I can move the world
alumni.unh.edu!kdc (PGP Key Available)        |


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to