From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18065 invoked by alias); 11 Apr 2016 10:22:56 -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: 38269 Received: (qmail 16646 invoked from network); 11 Apr 2016 10:22:55 -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=1pN3zKQqcz2NguZHIPEyaba92HdeFiVa0YrT0VSDVow=; b=qoxTkz3T+hnn/dN/ipYIhl7Yo7oxNndQY9qGQLJOEDLeiENFDNQUcsCILj1Qwo9Gg8 FiluMOZeBYPF9mUamMSjp+1tcOmigtF6kRZQwu7YIe4m0ZQ/6S9uORaLExuQCxoZwNjR DpS7ltpnynO3uEa75tSCjrcuHj2RychJqeMMCFj10QEZ0k58OpwZEcVEh6TcRFXQhk3C g1vGTF4yxz93kCHlL2K1sceRWyrzHAEUpia2ka+xJ4Na+fGKMwseWOJ0MR2aRObayjJY g4PEo/8RZHSgfm9gpExwOiuHeAGTnDGN8aIgEBtPkfHR01FfUW5HDkt/tH/DTGgnrhBP a8RQ== 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=1pN3zKQqcz2NguZHIPEyaba92HdeFiVa0YrT0VSDVow=; b=Z9gy0BPHs29lMjOABgbYBSFaxf2eLg+YEXRy5hAGYTPbIvBviM/pEm6qJKkPr6VNFV whqZ6SawVFBaEzatjzsriyG+LZQcNC1UTOPV2AWIEbpZ9FvowSL3yg6D3DlwOxcNh7C9 p/C3fZW0aKznM+iUhhQRa1BJ/vSvk3YL8KqWcE2B5Hq2mYwaQVEdaL4CClI5ZWYX6KKb czYGemwtx0SrK32Dv+WdWjMRS7CZExbzQw+uNdt/D2Upy5BoIeygq8W2/n1FCdfquoEp h0i6YqlXTuOxt4y+SheYZnx557+wQU/JqraBOSYmwgviMoPwHDFpxVWxOtfZy6HW73vy +aMQ== X-Gm-Message-State: AOPr4FVRIDPV6ooBhC1zZhQwesre+WhOpzM+sDeonxyeE7xjPE8qJFltILs6B8IZNsFKQHBha5iAjDPgBP6e2w== MIME-Version: 1.0 X-Received: by 10.141.46.71 with SMTP id x68mr12205686qhe.70.1460370169904; Mon, 11 Apr 2016 03:22:49 -0700 (PDT) In-Reply-To: <20160411093738.11406966@pwslap01u.europe.root.pri> References: <160410151105.ZM21544@torch.brasslantern.com> <20160411093738.11406966@pwslap01u.europe.root.pri> Date: Mon, 11 Apr 2016 12:22:49 +0200 Message-ID: Subject: Re: Allow slash in alternation patterns in limited cases? From: Mikael Magnusson To: Peter Stephenson Cc: zsh workers Content-Type: text/plain; charset=UTF-8 On Mon, Apr 11, 2016 at 10:37 AM, Peter Stephenson wrote: > On Sun, 10 Apr 2016 15:11:05 -0700 > Bart Schaefer wrote: > >> On Apr 10, 10:36pm, Mikael Magnusson wrote: >> } >> } /path/(to/file|or/another/file) # nope, too hard >> } (/path/to/a/dir/*|/path/to/some/other/files/*) # can we allow this? >> >> My gut feeling is that this is close to impossible. > > The problem's not the parsing, it's the fact that you don't have > appropriate chunks corresponding to directories for the scanner to loop > over once pattern matching has parsed it. > > The only way I can see is effectively to parse it first in the globbing > code to treat a complete set of parentheses specially. Yeah, that's what I had in mind too as the possibility. This is probably naive but I imagined we would see the ( and go "ah, the matching ) is at the end [and there's only glob qualifiers after it], so i'll loop over each alternatee and push them on the pile of glob results, and then apply the qualifiers". > But this is > going to be inconsistent with pattern matching one way or another. So a > different syntax would be more sensible. Doesn't this already work as is with pattern matching? Eg, I could do /path/to/**/*~^(/path/to/a/dir/*|/path/to/some/other/files/*) even though that would be insanely inefficient, especially when /path/to is just /. >> } If not, would it be possible to invent some new syntax to "paste" two >> } or more globs together so that a single set of glob >> } quals/sorts/flags/subscripts could apply to it? > > I think Bart's answered this. This occurred to me just now, a=( (/path/to/a/dir/*|/path/to/some/other/files/*) ) echo .(e*'reply=($a)'*om[1]) This works syntactically, the only problem seems to be that sort qualifiers do nothing on matches inserted by e::, nor do ones like . and / (they all just act on the original . which is probably reasonable). It's also pretty ugly to have to act on a dummy match. -- Mikael Magnusson