Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: unset path problem



Peter Stephenson wrote:
> > Richard Curnow wrote:
> > > If I change MANPATH, I don't see manpath getting changed.
> > 
> > You haven't unset that in your .zshenv too, have you?
> 
> Maybe the answer is to make sure `createparam' is called for the other
> value if it is also unset?

It does seem to be this simple; it's logical that if they both get unset at
once, but retain their specialness, then they should both be recreated at
once.  I've added a couple of tests for this and the bug fixed by Bart, and
some documentation for special tied variables --- was there really none
before, or have I missed it?

Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.45
diff -u -r1.45 params.c
--- Src/params.c	2001/05/19 00:31:23	1.45
+++ Src/params.c	2001/05/19 23:36:50
@@ -669,6 +669,12 @@
 	if (oldpm && (oldpm->level == locallevel || !(flags & PM_LOCAL))) {
 	    if (!(oldpm->flags & PM_UNSET) || (oldpm->flags & PM_SPECIAL)) {
 		oldpm->flags &= ~PM_UNSET;
+		if ((oldpm->flags & PM_SPECIAL) && oldpm->ename) {
+		    Param altpm = 
+			(Param) paramtab->getnode(paramtab, oldpm->ename);
+		    if (altpm)
+			altpm->flags &= ~PM_UNSET;
+		}
 		return NULL;
 	    }
 	    if ((oldpm->flags & PM_RESTRICTED) && isset(RESTRICTED)) {
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.1
diff -u -r1.1 D04parameter.ztst
--- Test/D04parameter.ztst	2001/04/02 12:34:06	1.1
+++ Test/D04parameter.ztst	2001/05/19 23:36:51
@@ -526,3 +526,23 @@
 >fixed
 >the
 >shell
+
+  unset SHLVL
+  (( SHLVL++ ))
+  print $SHLVL
+0:Unsetting and recreation of numerical special parameters
+>1
+
+  unset manpath
+  print $+MANPATH
+  manpath=(/here /there)
+  print $MANPATH
+  unset MANPATH
+  print $+manpath
+  MANPATH=/elsewhere:/somewhere
+  print $manpath
+0:Unsetting and recreation of tied special parameters
+>0
+>/here:/there
+>0
+>/elsewhere /somewhere
Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.7
diff -u -r1.7 params.yo
--- Doc/Zsh/params.yo	2001/04/22 21:02:33	1.7
+++ Doc/Zsh/params.yo	2001/05/19 23:36:52
@@ -632,7 +632,17 @@
 enditem()
 texinode(Parameters Used By The Shell)()(Parameters Set By The Shell)(Parameters)
 sect(Parameters Used By The Shell)
-The following parameters are used by the shell:
+The following parameters are used by the shell.
+
+In cases where there are two parameters with an upper- and lowercase
+form of the same name, such as tt(path) and tt(PATH), the lowercase form
+is an array and the uppercase form is a scalar with the elements of the
+array joined together by colons.  These are similar to tied parameters
+created via `tt(typeset -T)'.  The normal use for the colon-separated
+form is for exporting to the environment, while the array form is easier
+to manipulate within the shell.  Note that unsetting either of the pair
+will unset the other; they retain their special properties when
+recreated, and recreating one of the pair will recreate the other.
 
 startitem()
 vindex(ARGV0)

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



Messages sorted by: Reverse Date, Date, Thread, Author