zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: **Zsh Workers List <zsh-workers@sunsite.auc.dk>
Subject: Re: typeset -U and "special-ness"
Date: Sun, 16 May 1999 15:22:59 +0200	[thread overview]
Message-ID: <9905161323.AA38780@ibmth.df.unipi.it> (raw)
In-Reply-To: "Scott RoLanD"'s message of "Sat, 15 May 1999 11:32:29 DFT." <19990515113229.A26292@chat.net>

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


      reply	other threads:[~1999-05-16 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-15 18:32 Scott RoLanD
1999-05-16 13:22 ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9905161323.AA38780@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).