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

Re: 'emulate sh -c' and $0



On Jun 3, 2014 1:27 PM, "Peter Stephenson" <p.w.stephenson@xxxxxxxxxxxx>
wrote:
>
> On Tue, 03 Jun 2014 16:15:25 -0400
> Richard Hansen <rhansen@xxxxxxx> wrote:
> > Although it would be a behavior change, I think it would be best if both
> > 'emulate sh' and 'emulate sh -c' set POSIX_ARGZERO by default
>
> Yes, that's the policy --- backward compatibility is for native mode, sh
> compatibility can be improved without worrying about that.

The complexity here is that we're not just dealing with a particular
emulation, we're dealing with switching from one emulation to another (and
possibly back again) in the middle of a running shell session, and the
effect that has on a dynamically scoped variable that crosses the emulation
boundaries.

If I start in zsh mode and change $0, or $PATH, or any other parameter, and
then enter  a different emulation, the values of those parameters don't
normally change.

> I'm not sure why we missed this one.  Most of the POSIX options are on
> in sh emulations.

We didn't really miss it -- FUNCTION_ARGZERO is correctly turned off when
in sh emulation.  The complication is that it affects $0 only upon entry to
the scope, so although $0 doesn't change *again*, it also doesn't revert if
it was changed previously.


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