Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Function code breaking out of if then ...fi



On Mon, 05 Nov 2012 14:29:42 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> It's not really like a break, it's like (well, is) a global error flag
> --- but the error status gets reset at the top level command loop,
> which we reach in a script after the end of a set of complex commands
> --- but only right at the end, when we're reading a new (possibly
> complex, arbitrarily nested) command from the script.
> 
> I think actually what's going on could be considered a bug which is an
> oversight for the case of scripts.

Hmmm... there are multiple loops here and they have different error
handling.

In loop(),

	if (((!interact || sourcelevel) && errflag) || retflag)
	    break;

This actually does what I want: if it's not interactive, and there's an
error, break out of the loop.  This is the "top level" loop I was
thinking of.

However, there are two even topper level loops in zsh_main().  They
appear to be limited to handling the case of hitting EOF and a parse
error --- no other sort of error --- however, and aren't restricted to
interactive behaviour.  I don't really like the look of the combination
of these three loops --- it smells to me like the effect hasn't been
thought through properly.  I can see you need to exit if you've got a
parse error, because you don't know what to execute yet, but I don't see
that you need to ignore all other errors in the outer loops.  retflag
and sourcelevel are irrelevant out here but I can definitely see a
case for "if (!interact && errflag) /* exit */".

pws



Messages sorted by: Reverse Date, Date, Thread, Author