From cb4ff5e9703d6641b10ca053f1caad2a8b19d2f9 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 22 Apr 2012 18:39:53 +0000 Subject: 30439: ${...:*...} with nonexistent or non-array after * should return no results --- ChangeLog | 8 ++++++-- Src/subst.c | 13 +++++++++++++ Test/D04parameter.ztst | 5 +++++ 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 + * 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) -- cgit 1.4.1