Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: short-circuiting glob exclusion operator
- X-seq: zsh-workers 38200
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: PATCH: short-circuiting glob exclusion operator
- Date: Mon, 21 Mar 2016 21:39:07 +0100
- Cc: "Zsh Hackers' List" <zsh-workers@xxxxxxx>
- 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 :cc; bh=xshArOMNN/LULwQkInfuXC5v1E4lqOglG8tfxlQrUyw=; b=H6aIzaaS4ZABzsguPRf89ax9dSrt+UhQUYQE2LagAlYWFXFcR3dvOQJHh+q1MPJaEy B7Hq83Tnlp0SoFhd4zjUyiuhhLu4H4QpeOxZo1RO9OrRTRoJOzqkx5MaiZDVGu+M2j4O /n+RnrmaIfENIHjIXxgzk0dz5cBKJAoJivLTtb9sfAB2zjfPtO1li9rV+d15ghvKnfOn WJBSP8LnGDOlxgtuzqo3fhsWzkF6OQY40lGVy612qHB/4/Zf0/K5GJckxmhkvbYIAGun V37V9roGK4p7CrV+p0anLllDnqOj5vhd/d4OyJEFn6h4RviSbVHNMQPAmdLlc4JIF5xY Dd/w==
- In-reply-to: <20160321183649.4fd4d72a@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160321183649.4fd4d72a@pwslap01u.europe.root.pri>
On Mon, Mar 21, 2016 at 7:36 PM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> This is a request for comments for now. I'm not yet entirely sure the
> pattern syntax with two tildes isn't going to cause problems (though I
> don't see what they would be), or that I've identified all the side
> effects that can happen.
>
> As an ultra brief summary, ~~ in a glob introduces a pattern that will
> prune directories on the way through in addition to acting in the normal
> exclusion fashion. So **/*~~*/foo stops at and ignores any directories
> called foo at any level(#1) on the way down. This is unlike a single
> tilde where exclusions are only performed after the complete set of
> matches is generated, so it's potentially much more efficient.
>
> (#1) Except the top. It's a bit anhoying you need (|*/).
Is it like (^foo/)##* then, except possibly easier to combine with
other patterns, and/or to stop on more complicated expressions? I
assume you could do **/*~~*/foo/(|*/)bar where * also can match across
multiple slashes to stop recursing in bar directories if we're already
in a foo directory. It's not immediately obvious to me how to achieve
that with (^foo/)##* so it's probably not possible ;).
Here's a possible problem with double tilde as the syntax:
% touch foo~ hi~ hello
% echo *~~hi*
foo~
If ~~ was special, this would mean * with hi* removed, and print hello
foo~ instead of just foo~, which could break existing users. Or more
dramatically like in this fictional example,
# remove all backup files except some I
# like to keep for plot purposes
rm *~~importantfile*
With the change this would wipe out both backups and originals.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author