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

Re: PATCH: emulate (Re: Prompt fun)

On Oct 7,  4:50pm, Zefram wrote:
} Subject: Re: PATCH: emulate (Re: Prompt fun)
} Bart Schaefer wrote:
} >Hmm.  I tend to think of it exactly the opposite way -- if I set errexit,
} >I generally want it to continue to apply down through functions I call,
} >because of exactly the circumstances you note -- scripts run from make,
} >which uses -e when it invokes the shell.
} Hmm.  Surely in that case, the functions in question are going to be ones
} written to be executed in the context of that particular script, and
} will be intended to have ERR_EXIT set, and won't have an emulate line?

The function might be written so that zsh executes it as an autoload but
bash runs it as a separate script process.  In the former case, an emulate
might be required.

However, I admit that there is merit in your argument; it's just that I
tend to want to resolve conflicts by *not* changing existing behavior ...

Which reminds me:  I believe the original intent of "emulate" was not to
reset _all_ options that might affect parsing (unless "emulate -R" is
used).  I believe the intent was to reset any option that would confuse
a ksh or sh script running in zsh.  Options like "cdablevars" and "autocd"
were *not* handled by "emulate" because no reasonable ksh script could
possibly depend upon those behaviors, nor could a correctly-working ksh
script use syntax that could accidentally trigger them.

Scripts that need to port among different users' zsh configurations, as
opposed to porting zsh<->ksh, were supposed to use "emulate -R" and then
setopt exactly the options they needed.

Perhaps the situation has changed enough, now that large parts of the zsh
distribution are written as zsh scripts, that we should revisit that and
make most of the changes in Zefram's patch.  On the other hand, I'm as
usual loathe to make "silent" changes to the option semantics.  I'd much
rather see an additional flag to "emulate" that catches these additional
problem cases.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

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