From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19360 invoked from network); 16 May 1999 13:47:35 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 May 1999 13:47:35 -0000 Received: (qmail 11636 invoked by alias); 16 May 1999 13:47:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6294 Received: (qmail 11628 invoked from network); 16 May 1999 13:47:21 -0000 Message-Id: <9905161323.AA38780@ibmth.df.unipi.it> To: **Zsh Workers List Subject: Re: typeset -U and "special-ness" In-Reply-To: "Scott RoLanD"'s message of "Sat, 15 May 1999 11:32:29 DFT." <19990515113229.A26292@chat.net> Date: Sun, 16 May 1999 15:22:59 +0200 From: Peter Stephenson 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 Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy