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

Re: emulate -R resets localoptions



On Jun 5, 11:58am, Andrej Borsenkow wrote:
} Subject: emulate -R resets localoptions
}
} emulate -R seems to reset *all* options, in particular localoptions. I find
} it confusing; it breaks my simple notion

Yes, you're right; the whole point of -R is in fact to reset *all* the
options, just like the doc says.

The effect of this on localoptions is semi-documented, but probably ought
to be stated explicitly in the doc somewhere.  If you look at the sample
functions that come with the distribution, you'll find that any of them
that use emulate use it like this:

	emulate -R zsh
	setopt localoptions

The reason I say it's semi-documented is:

LOCAL_OPTIONS
     If this option is set at the point of return from a shell
     function, all the options (including this one) which were in force
     upon entry to the function are restored.

Note "at the point of return."  That means you have to be sure to set
localoptions only after you're sure nothing else is going to change it.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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