zsh-users
 help / color / mirror / code / Atom feed
* local after setopt allexport?
@ 1996-08-06 19:38 Rik Faith
  1996-08-07  7:29 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Rik Faith @ 1996-08-06 19:38 UTC (permalink / raw)
  To: zsh-users; +Cc: faith

Is there a way to keep variables from being exported after setopt
allexport?

With setopt allexport:

proteus /tmp/zsh-3.0-pre6> Src/zsh
proteus% setopt allexport   
proteus% typeset +x foo=bar
proteus% typeset -x bar=foo 
proteus% Src/zsh
proteus% echo $foo
bar
proteus% echo $bar
foo


Without setopt allexport:

proteus /tmp/zsh-3.0-pre6> Src/zsh
proteus% typeset +x foo=bar
proteus% typeset -x bar=foo 
proteus% Src/zsh
proteus% echo $foo

proteus% echo $bar
foo


(No ~/.z* startup files exist.  I couldn't find this in the info pages, the
FAQ, or the mailing list archives (to May 1995).  I'm new to this list, so
if there is some documentation I should have read, please let me know.
Thanks, Rik.)


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

* Re: local after setopt allexport?
  1996-08-06 19:38 local after setopt allexport? Rik Faith
@ 1996-08-07  7:29 ` Peter Stephenson
  1996-08-09  2:50   ` Rik Faith
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 1996-08-07  7:29 UTC (permalink / raw)
  To: Rik Faith, zsh-users

faith@cs.unc.edu wrote:
> Is there a way to keep variables from being exported after setopt
> allexport?

Variables are only exported when set, so you can temporarily unset the
option and set the variable in a shell function to get this effect.
You might need to make `noexport' more sophisticated.

% setopt allexport
% foo=bar 
% printenv foo
bar
% unset foo
% noexport() { setopt localoptions; unsetopt allexport; $1=$2; }
% noexport foo bar
% printenv foo
% print $foo
bar

-- 
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] 4+ messages in thread

* Re: local after setopt allexport?
  1996-08-07  7:29 ` Peter Stephenson
@ 1996-08-09  2:50   ` Rik Faith
  1996-08-09  5:44     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Rik Faith @ 1996-08-09  2:50 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Rik Faith, zsh-users

On Wed  7 Aug 1996 09:29:22 +0200,
   Peter Stephenson <pws@ifh.de> wrote:
> faith@cs.unc.edu wrote:
> > Is there a way to keep variables from being exported after setopt
> > allexport?
> 
> Variables are only exported when set, so you can temporarily unset the
> option and set the variable in a shell function to get this effect.
> You might need to make `noexport' more sophisticated.

Thanks for the work-around.

If this is not a compatibility or historical practice issue, I'd like to
suggest that the commands "local", "typeset", etc. all look like they are
used to declare the "type" of a variable.  As such, it seems that
"exportable" is a type attribute and that this attribute should be
associated with a variable for the remainder of its lifetime (or until
another typeset).  This could be implemented internally in zsh with a
tri-state flag: +x for exportable, -x for local, and ?x for "use the
current state of the allexport option".  If the export semantics in zsh can
be changed (and the maintainers are willing), I'll try to submit patches.
(But I don't want to do this if the current semantics are required by, for
example, ksh.)


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

* Re: local after setopt allexport?
  1996-08-09  2:50   ` Rik Faith
@ 1996-08-09  5:44     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1996-08-09  5:44 UTC (permalink / raw)
  To: Peter Stephenson, Rik Faith, zsh-users

On Aug 8, 10:50pm, Rik Faith wrote:
} Subject: Re: local after setopt allexport?
}
} If this is not a compatibility or historical practice issue, I'd like to
} suggest that the commands "local", "typeset", etc. all look like they are
} used to declare the "type" of a variable.  As such, it seems that
} "exportable" is a type attribute and that this attribute should be
} associated with a variable for the remainder of its lifetime (or until
} another typeset).

This is in fact what happens when `allexport' is NOT set.

} This could be implemented internally in zsh with a
} tri-state flag: +x for exportable, -x for local, and ?x for "use the
} current state of the allexport option".

It'd have to be +x for local, -x for exported, to be consistent with
existing usage.

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

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"


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

end of thread, other threads:[~1996-08-09  5:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-06 19:38 local after setopt allexport? Rik Faith
1996-08-07  7:29 ` Peter Stephenson
1996-08-09  2:50   ` Rik Faith
1996-08-09  5:44     ` 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).