zsh-workers
 help / color / mirror / code / Atom feed
* typeset -U and "special-ness"
@ 1999-05-15 18:32 Scott RoLanD
  1999-05-16 13:22 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Scott RoLanD @ 1999-05-15 18:32 UTC (permalink / raw)
  To: **Zsh Workers List

I love 'typeset -U' for paramaters like PATH, MAILPATH, and
MANPATH. However, I was disappointed to learn that 'typeset -U
LD_LIBRARY_PATH' has no effect.

I understand that 'typeset -U' only works for "special" paramaters,
but why? How did MANPATH get elevated to the status of a "special"
paramater when it isn't used by the shell at all?

Also, 'typeset -U' doesn't remove duplicates from current values of
the paramaters. Any good reason for this?
For example:
	% unset MANPATH
	% typeset +U MANPATH
	% echo $MANPATH

	% MANPATH=foo:foo
	% echo $MANPATH
	foo:foo
	% typeset -U MANPATH		<- Why not effect the value?
	% echo $MANPATH
	foo:foo
	% MANPATH=$MANPATH
	% echo $MANPATH
	foo

What do you think?
-- 
Scott RoLanD
http://www.chat.net/~shr/


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

* Re: typeset -U and "special-ness"
  1999-05-15 18:32 typeset -U and "special-ness" Scott RoLanD
@ 1999-05-16 13:22 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1999-05-16 13:22 UTC (permalink / raw)
  To: **Zsh Workers List

Scott RoLanD wrote:
> I love 'typeset -U' for paramaters like PATH, MAILPATH, and
> MANPATH. However, I was disappointed to learn that 'typeset -U
> LD_LIBRARY_PATH' has no effect.
> 
> I understand that 'typeset -U' only works for "special" paramaters,
> but why? How did MANPATH get elevated to the status of a "special"
> paramater when it isn't used by the shell at all?

It was presumably just a random choice; at the time, MANPATH was much more
frequently used than LD_LIBRARY_PATH.

In the current development version, and so presumably in 3.1.6, you
are/will be able to do,
  typeset -TU LD_LIBRARY_PATH ld_library_path
to tie a colon-separated array to a shell array.  This will then work in
the same as special tied parameters, so the -U flag is useful even if you
never use $ld_library_path directly.  (It's too much work to eliminate the
real array.)  Arguably, we could then remove the specialness of MANPATH,
and just initialise it as an ordinary tied array which the user can then
unset if they want.

> Also, 'typeset -U' doesn't remove duplicates from current values of
> the paramaters. Any good reason for this?

You'll find it does if you turn on uniqueness for the array version of the
parameter, i.e. manpath instead of MANPATH.  I suppose this was just an
oversight.  The following patch makes it do the same when you use the
colon-array version of the parameter.

--- Src/builtin.c.uniq	Tue May 11 11:20:53 1999
+++ Src/builtin.c	Sun May 16 15:09:59 1999
@@ -1521,9 +1521,14 @@
 	    zerrnam(cname, "%s: restricted", pname, 0);
 	    return pm;
 	}
-	if (PM_TYPE(pm->flags) == PM_ARRAY && (on & PM_UNIQUE) &&
-	    !(pm->flags & PM_READONLY & ~off))
-	    uniqarray((*pm->gets.afn) (pm));
+	if ((on & PM_UNIQUE) && !(pm->flags & PM_READONLY & ~off)) {
+	    Param apm;
+	    if (PM_TYPE(pm->flags) == PM_ARRAY)
+		uniqarray((*pm->gets.afn) (pm));
+	    else if (PM_TYPE(pm->flags) == PM_SCALAR && pm->ename &&
+		     (apm = (Param) paramtab->getnode(paramtab, pm->ename)))
+		uniqarray((*apm->gets.afn) (apm));
+	}
 	pm->flags = (pm->flags | on) & ~off;
 	/* This auxlen/pm->ct stuff is a nasty hack. */
 	if ((on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z | PM_INTEGER)) &&

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


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

end of thread, other threads:[~1999-05-16 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-15 18:32 typeset -U and "special-ness" Scott RoLanD
1999-05-16 13:22 ` 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).