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

Re: PATCH: emulate (Re: Prompt fun)

Bart Schaefer wrote:
>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.

Those two will rarely make any difference.  I can imagine, though,
scripts that tentatively attempt to execute a command, and may well have
unexpected behaviour if they start cd'ing around as a result.

emulate -R is there to change the shell completely to the specified
emulation, as if it had been started under that name.  It's useful
primarily in interactive shells.  emulate without -R is supposed to
emulate (hence the name) the specified shell, as much as necessary for
scripts to be able to run unchanged (subject to the limited capabilities
of zsh to emulate other shells).  To do this, emulate without -R really
needs to set all options that affect script behaviour.

>                                             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.

So when would we use this additional flag?  It would have to be used
essentially all the time, with plain emulate left just for backward
compatibility.  I find it difficult to believe that anything actually
relies on "emulate zsh" *not* resetting EXTENDED_GLOB.


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