summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c15
-rw-r--r--Test/B02typeset.ztst9
3 files changed, 25 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 84ed5c287..97bf9bb77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-13  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 25662: Src/builtin.c, Test/B02typeset.ztst: declare -p
+	should never create variables.
+
 2008-09-13  Clint Adams  <clint@zsh.org>
 
 	* 25656: Src/params.c: free val only after it may be passed to
diff --git a/Src/builtin.c b/Src/builtin.c
index 8adc7fcb1..8246453f4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2473,10 +2473,17 @@ bin_typeset(char *name, char **argv, Options ops, int func)
 
     /* Take arguments literally.  Don't glob */
     while ((asg = getasg(*argv++))) {
-	if (!typeset_single(name, asg->name,
-			    (Param) (paramtab == realparamtab ?
-				     gethashnode2(paramtab, asg->name) :
-				     paramtab->getnode(paramtab, asg->name)),
+	HashNode hn = (paramtab == realparamtab ?
+		       gethashnode2(paramtab, asg->name) :
+		       paramtab->getnode(paramtab, asg->name));
+	if (OPT_ISSET(ops,'p')) {
+	    if (hn)
+		printparamnode(hn, printflags);
+	    else
+		zwarnnam(name, "no such variable: %s", asg->name);
+	    continue;
+	}
+	if (!typeset_single(name, asg->name, (Param)hn,
 			    func, on, off, roff, asg->value, NULL,
 			    ops, 0))
 	    returnval = 1;
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 34e2dab26..abb549ed6 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -444,3 +444,12 @@
 0:Lower case conversion, does not apply to values used internally
 >lower
 >value of $lower
+
+ typeset -a array
+ array=(foo bar)
+ fn() { typeset -p array nonexistent; }
+ fn
+0:declare -p shouldn't create scoped values
+>typeset -a array
+>array=(foo bar)
+?fn:typeset: no such variable: nonexistent