From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2139 invoked by alias); 21 Mar 2016 20:39:12 -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: 38200 Received: (qmail 17751 invoked from network); 21 Mar 2016 20:39:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=xshArOMNN/LULwQkInfuXC5v1E4lqOglG8tfxlQrUyw=; b=dyXBBXgL7nEPtfMCIeh2LbwTkYQa2cHdVGbxLQx482TCnVstipR7qJuy7YROYiFOnI S+5u+ZC1SFTn8Ixb+P6GOvVAUjmHqvsWjuS50f1/b9MmVcin9spVeA8VekhLXVhaB43W xKCvXlyi7zaa7ZE7VSdCgPAE55UCCC7y1PneP3TGGU7vrZFCH/SaWG5NrtA0TeeVErzt Hvtlrs4/xtcyGNCCn3U61wdbDj29fJpytjWCFAkAHgymqu1aLtlyPKmFsOXf5VVTUewS gDDHxgBnmsw4vBeSsQwqrZ0Rr4V40WhT+BlxzVfPrZL91j+zm5GS/rbeGgzeH5qOdjrK H5zw== X-Gm-Message-State: AD7BkJJT5fjnuAp+kBGI8o4vaQVMbCqhoFRf6YL1H4xTeI19Fq0HzGnXLD+IC3DB1ExvMSOLOHIp+POh9lieeA== MIME-Version: 1.0 X-Received: by 10.55.217.151 with SMTP id q23mr42452377qkl.88.1458592747614; Mon, 21 Mar 2016 13:39:07 -0700 (PDT) In-Reply-To: <20160321183649.4fd4d72a@pwslap01u.europe.root.pri> References: <20160321183649.4fd4d72a@pwslap01u.europe.root.pri> Date: Mon, 21 Mar 2016 21:39:07 +0100 Message-ID: Subject: Re: PATCH: short-circuiting glob exclusion operator From: Mikael Magnusson To: Peter Stephenson Cc: "Zsh Hackers' List" Content-Type: text/plain; charset=UTF-8 On Mon, Mar 21, 2016 at 7:36 PM, Peter Stephenson 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