Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Function code breaking out of if then ...fi
On Fri, Nov 02, 2012 at 02:39:11PM -0700, Bart Schaefer wrote:
> On Nov 2, 10:09am, Michal Maruska wrote:
> }
> } I wonder if the following behaviour is a bug, or
> } simply my wrong expectation:
> }
> } This script, assuming the globbing fails, and I'm not using NULL_GLOB,
> } does not bother finishing the commands in the "then ....fi" block,
> } instead continues after "fi".
>
> This doesn't really have anything to do with the function. The same
> thing happens with
>
> if true;
> then
> echo non-existing*
> exit 0
> fi
>
> What slightly surprises me is that a glob failure isn't considered an
> error for purposes of ERR_EXIT (the -e option in your #! line). I
> would have expected the whole script to quit at that point, but I guess
> glob errors are not treated as command failures because the command
> never executes in the first place.
>
On my latop, if use 'echo non-existing*' in the if command, the
script will exit immediately, looks like the glob failure is
considered an error of ERR_EXIT. And changing to
{ echo non-existing* } always { TRY_BLOCK_ERROR=0 }
doesn't help, it still exits immediately. In the contrast, using 'fn'
won't trigger ERR_EXIT.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author