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

Re: PATCH: emulate (Re: Prompt fun)



Bart Schaefer wrote:
>I disagree with a number of these changes, particularly promptbang,
>promptpercent, and promptsubst.  Most scripts do not alter the values
>of PS[1234], and resetting the prompt-expansion options will cause the
>user's settings to display as garbage in conjunction with either use
>of "select" loops or (as of 3.1.6) "setopt xtrace"/"set -x".

I changed them to *not* be set by emulate.  They're a user interaction
matter, and really can't directly affect the operation of scripts,
so should not be set by emulate.

>I further think it's unwise to have emulate reset either errexit or
>"exec" -- though I don't see how it could possibly make any difference
>to the latter, as emulate itself won't be executed if exec isn't set.

I was a bit dubious about these, and a few others with that type of
meta effect, such as XTRACE.  On reflection, I think the criterion that
needs to be used is "is it valid to change this option within a script,
as a programming technique?".  "emulate -L zsh" is really the idiom used
to get known standard behaviour in a zsh function, so everything that
affects the direct behaviour of the function should be set by it.

With ERR_EXIT, I was imagining that a user might set the option in a
script (it can be quite convenient in scripts run from make), and then
call a function that doesn't want ERR_EXIT set -- the function should
decide for itself how to handle errors.  Applying the criterion I state
above, it is normal to set this option within a script -- it has the
effect of suffixing all commands with "|| exit", which is sometimes what
one wants.

For EXEC, really there's no reason to change it within a script.  Its sole
purpose is for syntax checking of a script, so I agree that it shouldn't
be considered to be emulation-relevant.

>                                                 Certainly I agree with
>some of the changes, e.g. the history options ought *not* to be reset.

Right.  Again, these are user interaction features, and don't affect
scripts.
>
>} The patch quoted above is still necessary; EXTENDED_GLOB is unset
>} by default even in zsh mode.  Would changing that break any scripts?
>
>Yes, it would break some of my scripts.

A pity.

-zefram



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