> > > #!/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 behavior is very confusing and apparently not documented. It's
> just plain weird that the compound statement containing "false" causes the
> function call to end up with a nonzero exit status only bacause the
> statement appears *on the last line* of the function. The exact same
> statement on the first line of the function behaves as expected.

As marked above, the line causing bash to exit is not line 1 (which
was a compound statement), but line 2 (invoking a function by a
simple statement).  Try rewriting line 2 as "func && echo false" to
see the difference.

-- 
Eric Blake


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to