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

Re: sourcing a sh file in zsh



On 2009-01-16 at 10:29 -0800, Bart Schaefer wrote:
> with the obvious meaning of "turn on sh emulation while sourcing" and
> would otherwise behave like "source".  Might need a variant that has
> the path-searching semantics of "." as well.

Isn't there a problem where a function is defined which assumes one set
of semantics and the reset afterwards changes the semantics?  Thus the
reason why the entry points into completion set the relevant emulation
options.

Really, we need to be able to have a function "remember" the options in
effect at the time it was defined and restore them, without having to
call emulate within them.

At $work there are some shell libraries which I could use if this were
doable, which is why my notes of Things I Want To Get Around To Making
Zsh Support includes this item:

----------------------------8< cut here >8------------------------------
zsh setopt inherit_options
When set, functions defined remember the options set at time of definition,
so it's similar to an automatic "emulate" in them.
Most usefully: setopt local_options inherit_options
function fred { setopt localoptions shwordsplit; alpha="foo bar baz bat"; print -l $alpha; function barney { print -l $alpha } }
(Multi-shell compatibility libraries)
----------------------------8< cut here >8------------------------------

Thoughts, comments?

I can see how to go about doing it but haven't gotten around to it yet.

-Phil



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