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

Re: 'emulate sh -c' and $0

On Jun 3, 2014 3:54 PM, "Richard Hansen" <rhansen@xxxxxxx> wrote:
> I was thinking more along the lines of temporarily
> restoring the top-level (non-emulated) option state when calling a
> function that was not defined inside of 'emulate <shell> -c'.  (Maybe
> there's not a significant implementation difference between what I'm
> thinking and assigning sticky options to all functions.)

Implementation aside, operationally this still violates dynamic scoping.
It means for example that the completion system can't set extendedglob on
entry and be sure it remains in effect throughout any helper functions it

The reason sticky emulation works the way it does is because it allows the
function author to explicitly assert that dynamic scoping should not apply
to the options in effect in that function, but the default scope is still
dynamic for all other functions.

It might be possible to introduce another builtin/precommand that
temporarily unwinds one level of option state before entering the next,
sort of a "go play at Grandma's house" wrapper ... but I haven't really
thought about how that could be done.  It would require exporting a bunch
of the local C state of doshfunc(), I bet.

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