zsh-workers
 help / color / mirror / code / Atom feed
* Re: local after setopt allexport?
       [not found] <960808224452.ZM21431@candle.brasslantern.com>
@ 1996-08-09  8:49 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1996-08-09  8:49 UTC (permalink / raw)
  To: Zsh hackers list

schaefer@candle.brasslantern.com wrote:
> I confess to be curious why:
> 
> 	setopt allexport
> 	typeset +x FOO=bar
> 
> results in FOO being exported, whereas
> 
> 	setopt allexport
> 	FOO=bar
> 	typeset +x FOO
> 
> results in FOO being local.  Does ksh really ignore the `+x' in the
> first example?  (I should get pdksh so I can stop asking this stuff,
> but then again, most of the time I don't *want* pdksh.)

It looks like ksh makes FOO local in both cases --- in fact, even
without the +x in the first case.  This is just one of many
inconsistencies with typeset which needs a much clearer logic.
Another is that typeset with an existing sufficiently local variable
reports the value, which is confusing in functions.  If I had a list
of all the things it should and shouldn't do I might attempt to
rewrite it one day.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: local after setopt allexport?
       [not found] <960809094225.ZM23675@candle.brasslantern.com>
@ 1996-08-12  8:03 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1996-08-12  8:03 UTC (permalink / raw)
  To: Zsh hackers list

schaefer@candle.brasslantern.com wrote:
> Great Manitoba!  Finally something that makes sense!  That would
> explain why "typeset" acts like "local" when used inside a function:
> because it *always* acts like "local".

That's mostly true of zsh too, with the exception that anything
exported becomes global, otherwise it was impossible to export anything
from a function.  Actually, the only difference there is that in zsh
you can't have `local -x', which you can in ksh; typeset -x in both
exports the variable globally.  In this case local and typeset behave
differently in ksh.

> What does ksh do with
> 
> 	FOO=bar
> 	export FOO
> 	typeset FOO=foo
> 
> ??  Does that make FOO local?

If called in a function it creates a new copy of FOO with the value
foo, leaving the exported value as bar.  Otherwise, it changes the
exported value.

None of this particularly increases my enthusiasm for either local
variable mechanism.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

end of thread, other threads:[~1996-08-12  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <960808224452.ZM21431@candle.brasslantern.com>
1996-08-09  8:49 ` local after setopt allexport? Peter Stephenson
     [not found] <960809094225.ZM23675@candle.brasslantern.com>
1996-08-12  8:03 ` Peter Stephenson

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).