From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14412 invoked by alias); 22 Apr 2012 18:25:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30439 Received: (qmail 21030 invoked from network); 22 Apr 2012 18:25:56 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.215.171 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-proxyuser-ip:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=KWPbFCNKcJSxbCkjCDXk4W+qgkXkCvSbD6F82EhlKRc=; b=QAw7XAbkIw+NYNzcdSGaZRdUSXp93l7aoKhwpZmFeBaxhDLu8UfOLY/drW3ct/6Ofs scHAbd6LiT9T6axymhAP/0hcmH9PeiBcL5P3yJYEUUwpo4IfpqCB6+MPw7s3/+vpQKx6 +M8W+vrg3h5ETlvNA7AkGguiuW2oorzYMxb9MWDy+Sf+xA1SPuopBwc7Q2x5JuXCVMAP jxELjfY4SMFV8GqYRDIMd14E6oMVuzn/pZPrf5Owb3Ccyr/zYFr+ybzKsYLigsl4cFnX z+zC1dLxUJ/HBPnsdAZsKfxYOhy6egXqxdyD10sns1Kwk6EVUl0KGRbOrhswI/JbUFl2 0KGg== X-ProxyUser-IP: 86.6.29.42 Date: Sun, 22 Apr 2012 19:20:36 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: PATCH: parameter substitution for exclusion by array Message-ID: <20120422192036.733be288@pws-pc.ntlworld.com> In-Reply-To: References: <20120420202051.367d012e@pws-pc.ntlworld.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn47bPY57w8tgrsYF/NOzS25KMwQnB/5GBF/X50UfbJR+WG0zEC6RT8rAI8vcyHmx3j3L5z On Sun, 22 Apr 2012 14:55:15 +0200 Mikael Magnusson wrote: > Using ${path:*notexist} prints all elements of $path, not sure if that > is what one should expect or not. ${path:|notexist} does the same but > that makes a lot more sense to me :). ${path:*SCALAR} and :| act the > same way, substitute all elements in $path. You're right that using :* with something that doesn't exist or isn't an array should produce an empty result, I hadn't picked up this difference from :|. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.135 diff -p -u -r1.135 subst.c --- Src/subst.c 22 Apr 2012 18:10:43 -0000 1.135 +++ Src/subst.c 22 Apr 2012 18:18:18 -0000 @@ -2918,6 +2918,19 @@ paramsubst(LinkList l, LinkNode n, char } } 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. */ /* Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.66 diff -p -u -r1.66 D04parameter.ztst --- Test/D04parameter.ztst 22 Apr 2012 18:10:43 -0000 1.66 +++ Test/D04parameter.ztst 22 Apr 2012 18:18:18 -0000 @@ -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) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/