zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: globbing in conditional expressions
Date: Mon, 4 Aug 2014 19:35:19 +0100	[thread overview]
Message-ID: <20140804193519.3b1c06ab@pws-pc.ntlworld.com> (raw)
In-Reply-To: <CAHYJk3S1GMeABMkU1fa4Uxz3oxOjnj+BJfUGxMN_zpY6tMTEVg@mail.gmail.com>

On Mon, 4 Aug 2014 19:16:01 +0200
Mikael Magnusson <mikachu@gmail.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2014-08-04 18:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140507154407.660eb500@pwslap01u.europe.root.pri>
     [not found] ` <20140508105522.GE2052@tarsus.local2>
     [not found]   ` <20140508122045.3c68c3fa@pwslap01u.europe.root.pri>
     [not found]     ` <140508083418.ZM14713@torch.brasslantern.com>
     [not found]       ` <20140508201936.GB53652@isis.sigpipe.cz>
     [not found]         ` <140513084117.ZM22925@torch.brasslantern.com>
     [not found]           ` <20140514041908.GF2471@tarsus.local2>
     [not found]             ` <140514001819.ZM23478@torch.brasslantern.com>
     [not found]               ` <20140515092901.GC2174@tarsus.local2>
     [not found]                 ` <140515075003.ZM28035@torch.brasslantern.com>
     [not found]                   ` <20140526235216.GC1920@tarsus.local2>
     [not found]                     ` <140529205956.ZM17410@torch.brasslantern.com>
     [not found]                       ` <20140530094752.4a116629@pwslap01u.europe.root.pri>
     [not found]                         ` <140530085542.ZM18304@torch.brasslantern.com>
2014-05-30 18:57                           ` Peter Stephenson
2014-05-30 19:19                             ` Peter Stephenson
2014-05-31 19:38                               ` Peter Stephenson
2014-06-01 18:20                                 ` Bart Schaefer
2014-08-04 17:16                                 ` Mikael Magnusson
2014-08-04 18:35                                   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140804193519.3b1c06ab@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).