On Mon, 22 Apr 2002, Derek D. Martin wrote:

=>-----BEGIN PGP SIGNED MESSAGE-----
=>Hash: SHA1
=>
=>At some point hitherto, Kevin D. Clark hath spake thusly:
=>> >    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.
=>
=>Not exactly... it's more subtle even than that.  For example:
=>
=>    result=badness    # init with failure default
=>    while read input
=>    do
=>        result=goodness
=>    done
=>    echo $result
=>
=>What is the result in this case?  The shell script outputs "goodness"
=>instead of "badness" as in the previous example.
This is a classic example of why I prefer doing actual script work in ksh 
and have my login shell as bash. The first example above will *not* have 
this side-effect in ksh.


-- 
-Time flies like the wind. Fruit flies like a banana. Stranger things have -
-happened but none stranger than this. Does your driver's license say Organ
-Donor?Black holes are where God divided by zero. Listen to me! We are all-
-individuals! What if this weren't a hypothetical question? [EMAIL PROTECTED]



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

Reply via email to