about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2001-05-19 23:47:58 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2001-05-19 23:47:58 +0000
commit6ea2dab092feb373c13a4dda85bc0d399978975a (patch)
treeecfe95f3bb44e53849d3519f81b95ecaa80b13fc
parentfbe51d3ee974988aa1f2ffcba748918b1845fb65 (diff)
downloadzsh-6ea2dab092feb373c13a4dda85bc0d399978975a.tar.gz
zsh-6ea2dab092feb373c13a4dda85bc0d399978975a.tar.xz
zsh-6ea2dab092feb373c13a4dda85bc0d399978975a.zip
Fix, test and comment unsetting and resetting of special tied parameters
-rw-r--r--Doc/Zsh/params.yo12
-rw-r--r--Src/params.c6
-rw-r--r--Test/D04parameter.ztst20
3 files changed, 37 insertions, 1 deletions
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 1ed1e2a0f..86f9c7d29 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -632,7 +632,17 @@ The version number of this zsh.
 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)
diff --git a/Src/params.c b/Src/params.c
index 28a8f1e85..63e1dc75c 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -669,6 +669,12 @@ createparam(char *name, int flags)
 	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)) {
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 7304f31d7..3bb143a33 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -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