Re: functions and set -e

2006-08-29 Thread Greg Schafer
On Wed, Aug 30, 2006 at 01:01:06AM -0400, Paul Jarc wrote: > Greg Schafer <[EMAIL PROTECTED]> wrote: > > Thanks for trying to clarify it for me. Let me put it another way: If I > > change Line 1 above to an if/then style statement instead of "&&" ie: > > > > if false; then echo false; fi > > > >

Re: functions and set -e

2006-08-29 Thread Paul Jarc
Greg Schafer <[EMAIL PROTECTED]> wrote: > Thanks for trying to clarify it for me. Let me put it another way: If I > change Line 1 above to an if/then style statement instead of "&&" ie: > > if false; then echo false; fi > > it works exactly like I'd expect instead of the counter-intuitive behavio

Re: functions and set -e

2006-08-29 Thread Greg Schafer
On Wed, Aug 30, 2006 at 04:28:35AM +, Eric Blake wrote: > > > > #!/bin/sh > > > > set -e > > > > > > > > func () { > > > > false && echo false > > > > true && echo true > > > > false && echo false > ^^^ Line 1 > > > > > } > > > > > > > > func > ^^^ Line 2 > > > > > > > > > echo done > >

Re: functions and set -e

2006-08-29 Thread Eric Blake
> > > #!/bin/sh > > > set -e > > > > > > func () { > > > false && echo false > > > true && echo true > > > false && echo false ^^^ Line 1 > > > } > > > > > > func ^^^ Line 2 > > > > > > echo done > > > > I'll take your word for it.. but I'm not totally convinced. At the very > least, this b

Re: functions and set -e

2006-08-29 Thread Greg Schafer
On Wed, Aug 30, 2006 at 12:03:51AM -0400, Paul Jarc wrote: > Greg Schafer <[EMAIL PROTECTED]> wrote: > > #!/bin/sh > > set -e > > > > func () { > > false && echo false > > true && echo true > > false && echo false > > } > > > > func > > > > echo done > > > > > > It never echoes "done" because

Re: functions and set -e

2006-08-29 Thread Paul Jarc
Greg Schafer <[EMAIL PROTECTED]> wrote: > #!/bin/sh > set -e > > func () { > false && echo false > true && echo true > false && echo false > } > > func > > echo done > > > It never echoes "done" because func() returns 1. That's the correct behavior. The last "false" within the function does

functions and set -e

2006-08-29 Thread Greg Schafer
Hi Here's a test case which demonstrates the problem: #!/bin/sh set -e func () { false && echo false true && echo true false && echo false } func echo done It never echoes "done" because func() returns 1. This seems to go against what the bash manual says about "set -e" "Exit immedia