summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2020-12-17 21:08:47 -0800
committerBart Schaefer <schaefer@ipost.com>2021-04-10 14:12:29 -0700
commit2eb9289d1277bf71b1b9dea2addbddd36b61f276 (patch)
tree6850a6161176739e6cc892a47a87a1ac4ff732aa
parentMake DECLAREDNULL require POSIXBUILTINS and introduce a new test file. (diff)
downloadzsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar.gz
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar.bz2
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar.lz
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar.xz
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.tar.zst
zsh-2eb9289d1277bf71b1b9dea2addbddd36b61f276.zip
Missed files from POSXIBUILTINS commit
-rw-r--r--Src/builtin.c5
-rw-r--r--Test/V10private.ztst12
2 files changed, 9 insertions, 8 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 8d8ff68e0..b0d4eb7f7 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2491,7 +2491,8 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
return NULL;
}
}
- pm->node.flags |= PM_DECLAREDNULL;
+ if (isset(POSIXBUILTINS))
+ pm->node.flags |= PM_DECLAREDNULL;
} else {
if (idigit(*pname))
zerrnam(cname, "not an identifier: %s", pname);
@@ -2891,7 +2892,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
* Don't attempt to set it yet, it's too early
* to be exported properly.
*
- * This creates the array with PM_DECLAREDNULL.
+ * This may create the array with PM_DECLAREDNULL.
*/
asg2.name = asg->name;
asg2.flags = 0;
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index a3a63867b..03e8259d5 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -19,14 +19,14 @@
() {
print $scalar_test
private scalar_test
- print $+scalar_test
+ typeset +m scalar_test
unset scalar_test
print $+scalar_test
}
print $scalar_test
0:basic scope hiding
>toplevel
->1
+>local scalar_test
>0
>toplevel
@@ -45,14 +45,14 @@
print $+unset_test
() {
private unset_test
- print $+unset_test
+ typeset +m unset_test
unset_test=setme
print $unset_test
}
print $+unset_test
0:variable defined only in scope
>0
->1
+>local unset_test
>setme
>0
@@ -62,13 +62,13 @@
local -Pa array_test=(in function)
() {
private array_test
- print $+array_test
+ typeset +m array_test
}
print $array_test
}
print $array_test
0:nested scope with different type, correctly restored
->1
+>local array_test
>in function
>top level