summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-04-22 18:39:53 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-04-22 18:39:53 +0000
commitcb4ff5e9703d6641b10ca053f1caad2a8b19d2f9 (patch)
tree0aa468fc42c6d92b6bf120af91a66af87651077f
parent5eb53bf88d3153510f0a5304e921b46419fe5721 (diff)
downloadzsh-cb4ff5e9703d6641b10ca053f1caad2a8b19d2f9.tar.gz
zsh-cb4ff5e9703d6641b10ca053f1caad2a8b19d2f9.zip
30439: ${...:*...} with nonexistent or non-array after *
should return no results
-rw-r--r--ChangeLog8
-rw-r--r--Src/subst.c13
-rw-r--r--Test/D04parameter.ztst5
3 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 64d199b15..5c3b37fba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,11 @@
2012-04-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
+ * Test/D04parameter.ztst: 30439: Src/subst.c,
+ Test/D04parameter.ztst: ${...:*...} with nonexistent or
+ non-array variable second should return no results.
+
* 30431 (typo in _typeset fixed):
- Completion/Zsh/Command/_typeset, Doc/Zsh/expn.yo, ASrc/params.c,
+ Completion/Zsh/Command/_typeset, Doc/Zsh/expn.yo, Src/params.c,
Src/subst.c, Test/D04parameter.ztst: add ${...:|...} and
${...:*...} operators for removal or inclusion of results
by array element.
@@ -16231,5 +16235,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5637 $
+* $Revision: 1.5638 $
*****************************************************
diff --git a/Src/subst.c b/Src/subst.c
index 82645ccfa..079d9efde 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2918,6 +2918,19 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
}
}
deletehashtable(ht);
+ } else if (intersect) {
+ /*
+ * The intersection with nothing is nothing...
+ * Seems a bit pointless complaining that the first
+ * expression is unset here if the second is, too.
+ */
+ if (!vunset) {
+ if (isarr) {
+ aval = mkarray(NULL);
+ } else {
+ val = dupstring("");
+ }
+ }
}
} else { /* no ${...=...} or anything, but possible modifiers. */
/*
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index d5a6a403e..cdeb15bfd 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -182,6 +182,9 @@
scalar='two words'
print ${scalar:|mod}
print ${scalar:*mod}
+ print ${args:*nonexistent}
+ empty=
+ print ${args:*empty}
0:"|" array exclusion and "*" array intersection
>one two
>#foo (bar 'three'
@@ -191,6 +194,8 @@
>two words
>
>two words
+>
+>
str1='twocubed'
array=(the number of protons in an oxygen nucleus)