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

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

On Nov 9, 10:52pm, Peter Stephenson wrote:
} On the behaviour that when the shell encounters a "fatal" error in a
} script it resumes at the next "top level" command:  here's a proposal.
} This makes that behaviour optional, for compatibility, but turns it off
} by default.  I don't think the old, undocumented, behaviour is intuitive
} enough for us to go on leaving it as the default.  The shell essentially
} skips a chunk of code and resumes later on at a point where there's not
} the slightest reason to suppose it's appropriate to do so; you might be
} relying on the structure that was previously executing to set things up
} for the next chunk of code.

I believe I know the reason for this behavior, and perhaps it points to a

When reading a startup file such as .zshrc, there is an intent to avoid
skipping the entire configuration just because of one erroneous command
somewhere in the middle.

My possibly flawed recollection was that this was only supposed to happen
in startup scripts, not in scripts run as standalone programs or loaded
by "source" or ".".

If this patch modifies the behavior of startup files, perhaps one further
step would be to turn on CONTINUE_ON_ERROR before startup files are read,
then turn it off before entering the main loop iff the starup files
themselves have not frobbed it.  I believe something similar is done
with MONITOR and also HASHDIRS.

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