zsh-workers
 help / color / mirror / code / Atom feed
* emulate -R resets localoptions
@ 1998-06-05  7:58 Andrej Borsenkow
  1998-06-05  8:44 ` Zefram
  1998-06-05  8:54 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Andrej Borsenkow @ 1998-06-05  7:58 UTC (permalink / raw)
  To: ZSH workers mailing list

emulate -R seems to reset *all* options, in particular localoptions. I find
it confusing; it breaks my simple notion, that I should be able to say

function foo() {
    setopt localoptions

and then set *any* option without fear, that it will mess the caller.

May be, there shoud be some flag (EXPLICIT or like), which says, that option
can be reset only explicitly?

============================================================
Andrej Borsenkow                Fax:   +7 (095) 796 99 20
SNI ITS Moscow                  Tel:   +7 (095) 796 99 24

NERV:  borsenkow.msk            E-Mail: borsenkow.msk@sni.de
============================================================



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emulate -R resets localoptions
  1998-06-05  7:58 emulate -R resets localoptions Andrej Borsenkow
@ 1998-06-05  8:44 ` Zefram
  1998-06-05  8:54 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Zefram @ 1998-06-05  8:44 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: zsh-workers

Andrej Borsenkow wrote:
>emulate -R seems to reset *all* options, in particular localoptions.

That's what it's supposed to do.  At least, it is supposed to reset all
configuration options -- it does not set the options relating to the
state of the shell, such as INTERACTIVE and PRIVILEGED.

>              it breaks my simple notion, that I should be able to say
>
>function foo() {
>    setopt localoptions
>
>and then set *any* option without fear, that it will mess the caller.

You can't set NO_LOCAL_OPTIONS without fear in any case.  Your `simple
notation' is wrong -- you should set LOCAL_OPTIONS *after* setting
other options.  LOCAL_OPTIONS is tested when the function returns,
not when options are set.

-zefram


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emulate -R resets localoptions
  1998-06-05  7:58 emulate -R resets localoptions Andrej Borsenkow
  1998-06-05  8:44 ` Zefram
@ 1998-06-05  8:54 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1998-06-05  8:54 UTC (permalink / raw)
  To: Andrej Borsenkow, ZSH workers mailing list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-06-05  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-05  7:58 emulate -R resets localoptions Andrej Borsenkow
1998-06-05  8:44 ` Zefram
1998-06-05  8:54 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).