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

Re: 'emulate sh -c' and $0

On Jun 3,  5:03pm, Bart Schaefer wrote:
} 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
} calls.

OK, that's not quite true.  What you're suggesting is not that the called
function has made the global options sticky, rather that if the calling
function has sticky options, it automatically reverts them upon making
a nested call.  So that would only mess up completion if somebody did
"emulate zsh -c compinit" to load it.

That still prevents the calling function from intentionally propagating
a particular set of options down to the called function, which I think
is the more common use case (certainly so far it has been the *only*
use case, though that may just be because no other is possible).

And as I suspected "reverts them" currently involves completing the C
fuction scope of doshfunc(), though that could be disentangled with a
bit of effort.

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