From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21963 invoked by alias); 4 Aug 2014 18:42:22 -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: 32954 Received: (qmail 7494 invoked from network); 4 Aug 2014 18:42:11 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.157.246] X-Spam: 0 X-Authority: v=2.1 cv=NutfcqtJ c=1 sm=1 tr=0 a=BvYiZ/UW0Fmn8Wufq9dPrg==:117 a=BvYiZ/UW0Fmn8Wufq9dPrg==:17 a=NLZqzBF-AAAA:8 a=pRTl07La5iUA:10 a=1pofwfMshjIA:10 a=uObrxnre4hsA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=yFGtzpRp5_9kveCQep4A:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=_dQi-Dcv4p4A:10 Date: Mon, 4 Aug 2014 19:35:19 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: globbing in conditional expressions Message-ID: <20140804193519.3b1c06ab@pws-pc.ntlworld.com> In-Reply-To: References: <20140507154407.660eb500@pwslap01u.europe.root.pri> <20140508105522.GE2052@tarsus.local2> <20140508122045.3c68c3fa@pwslap01u.europe.root.pri> <140508083418.ZM14713@torch.brasslantern.com> <20140508201936.GB53652@isis.sigpipe.cz> <140513084117.ZM22925@torch.brasslantern.com> <20140514041908.GF2471@tarsus.local2> <140514001819.ZM23478@torch.brasslantern.com> <20140515092901.GC2174@tarsus.local2> <140515075003.ZM28035@torch.brasslantern.com> <20140526235216.GC1920@tarsus.local2> <140529205956.ZM17410@torch.brasslantern.com> <20140530094752.4a116629@pwslap01u.europe.root.pri> <140530085542.ZM18304@torch.brasslantern.com> <20140530195734.1d9c5310@pws-pc.ntlworld.com> <20140530201942.580abc43@pws-pc.ntlworld.com> <20140531203800.154fc92d@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 On Mon, 4 Aug 2014 19:16:01 +0200 Mikael Magnusson wrote: > However, > % [[ alpha.c = (#b)(*).c(#q.) ]] > zsh: no matches found: (#b)(*).c(#q.) > > This example no longer works. Oh, you mean if alpha.c doesn't exist, since it's doing now globbing rather than pattern matching. Probably we oughtn't to be doing the special glob thing if the argument is already being treated as a pattern. This could probably do with a test. diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 8394ffc..9bff013 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -2338,7 +2338,9 @@ avoided for the sake of clarity. Note that within conditions using the `tt([[)' form the presence of a parenthesised expression tt(LPAR()#q...+RPAR()) at the end of a string indicates that globbing should be performed; the expression may include glob qualifiers, but -it is also valid if it is simply tt(LPAR()#q+RPAR()). +it is also valid if it is simply tt(LPAR()#q+RPAR()). This does +not apply to the right hand side of pattern match operators as the +syntax already has special significance. A qualifier may be any one of the following: diff --git a/Src/cond.c b/Src/cond.c index 3807409..df90656 100644 --- a/Src/cond.c +++ b/Src/cond.c @@ -297,8 +297,7 @@ evalcond(Estate state, char *fromtest) right = dupstring(opat = ecrawstr(state->prog, state->pc, &htok)); - if (htok) - cond_subst(&right, !fromtest); + singsub(&right); save = (!(state->prog->flags & EF_HEAP) && !strcmp(opat, right) && pprog != dummy_patprog2); diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 358c934..d7a0fae 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -533,14 +533,12 @@ cd glob.tmp [[ -n a*(#qN) ]] && print File beginning with a [[ -z z*(#qN) ]] && print No file beginning with z - [[ "a b c" = ?(#q) ]] && print Multiple files matched setopt nonomatch [[ -n z*(#q) ]] && print Normal string if nullglob not set ) 0:Force glob expansion in conditions using (#q) >File beginning with a >No file beginning with z ->Multiple files matched >Normal string if nullglob not set (){ print $#@ } glob.tmp/dir*(Y1) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/