Zsh Mailing List Archive
Messages sorted by:
Re: globbing in conditional expressions
- X-seq: zsh-workers 32950
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: "Zsh Hackers' List" <zsh-workers@xxxxxxx>
- Subject: Re: globbing in conditional expressions
- Date: Mon, 4 Aug 2014 19:16:01 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=xgygzJEf3elMCBwVjuD03PWz0eqrUWnbQ1hh50PoG4s=; b=p/gfpUmzQY/u5mLrtp8GAH9INXShe9ZpkghbRYUuJpz/gnN7Tv7Es/xFGBGGHV2bI6 rG3r0ciUnJMCbeHiQ9UafC9Xse8j1iXhILklT7hmlWtWbG86lgeK0LCep5nZxcHXEF+A JFSSpCfrRmb1fLlUg5KFXKHUf5YCOSpA+l/vulZwxWY/uczyqmGlpkXums5Z0Y5E4kZV PQeoKZpKtsloCJGX43L9yCf4bSwiolWxyxuSr82NRHf28HiCOpMLpNICjXg0MggIcwcy X7+CBH2SZ144xBt/sqMnNLJtLDAz0mspuaHMxsNOpFsB56FstmdQnaECoyfdUhy3tcUo 1YLQ==
- In-reply-to: <email@example.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <firstname.lastname@example.org> <20140508105522.GE2052@tarsus.local2> <email@example.com> <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> <firstname.lastname@example.org> <140530085542.ZM18304@torch.brasslantern.com> <email@example.com> <firstname.lastname@example.org> <email@example.com>
On 31 May 2014 21:38, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Fri, 30 May 2014 20:19:42 +0100
> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
>> On Fri, 30 May 2014 19:57:34 +0100
>> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
>> > One thing we could do is make [[ ... = ... ]] expand its right hand
>> > argument the same way as normal command arguments when told to do so, so
>> > there's no retokenization.
>> No reason not to do this for all string arguments, I suppose --- there's
>> nothing here that's specific to pattern matching.
> Here's a finalish patch with test and documentation, if anyone wants to
> comment. Haven't thought of a good reason not to do this, myself.
> diff --git a/NEWS b/NEWS
> index e4d747e..87e67fd 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -58,6 +58,13 @@ between the right hand side of the screen (this causes problems with
> some terminals). It is not special and is not set by default; the
> effect in that case is as if it was 1, as in previous versions.
> +If the option EXTENDED_GLOB is in effect, it is possible to force
> +globbing within conditional code using the [[ ... ]] syntax by flagging
> +that a certain string is a glob using the (#q) glob qualifier syntax.
> +The resulting glob is treated as a single argument. For example,
> +[[ -n *.c(#qN) ]] tests whether there are any .c files in the current
I was looking at the NEWS file since I figured I should maybe add :^
there, when I noticed this section added in this patch. I suddenly
remembered this example in the manpage which for some reason did not
come to mind while this patch was being discussed;
q A `q' and everything up to the closing parenthesis of the globbing
flags are ignored by the pattern matching code. This is
support the use of glob qualifiers, see below. The
result is that the
pattern `(#b)(*).c(#q.)' can be used both for globbing
and for match‐
ing against a string. In the former case, the `(#q.)'
will be treated
as a glob qualifier and the `(#b)' will not be useful,
while in the
latter case the `(#b)' is useful for backreferences and
will be ignored. Note that colon modifiers in the glob
also not applied in ordinary pattern matching.
% [[ alpha.c = (#b)(*).c(#q.) ]]
zsh: no matches found: (#b)(*).c(#q.)
This example no longer works.
Messages sorted by: