From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14776 invoked by alias); 24 Jun 2011 02:00:52 -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: 29504 Received: (qmail 5595 invoked from network); 24 Jun 2011 02:00:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.220.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=P/0E5Of4i9GgBDBhnoZlCNUnQBRftD8cfHS8i64tw1Y=; b=XnwpVZfhBXQ3oWohCLYotCWW+58zi9QuU8U3OrrBp/wiTZl5QQJg6GA4wbRKAG3Nyg EFsjtczmbm19eCBs26J7dIi4E5KStOXAthyZQPGoBlGvsMlYVaZ/ZjgXMvCuOxMC0Ezd V45DNruID/1sD7KM/VJHba0qIJjd9Y5oKaPT8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=K3ILlRW2s4VP+Eyh1TJZivQ6R//J2ALttyVeaXZa2/pV6S0C4Jis3YXJAzcDddp14Z GXCANORYXjIAR1LIo8Z/FS/7iGO8iXA1VKEsAXhMs4nzhGwFlYWar+iz1Fxcr55QySF+ HJILSnDKHGUeaFlpu3sdy9DgG4vrdFJD9O1HQ= MIME-Version: 1.0 Date: Fri, 24 Jun 2011 04:00:43 +0200 Message-ID: Subject: (#cN,M) error, %? doesn't glob From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 Someone asked on irc if there was a way to limit **/foo to 2 levels, and I explained how **/ is short for (*/)# so he should be able to use (*/)(#c,2), but that produces a bad pattern error. The manual says that "The flag (#cN,M) can be used anywhere that the # or ## operators can be used". (*/)# is special-cased together with **/ in parsecomplist(), so it is nontrivial to make it parse (#c) stuff, so here's an update for the documentation to add an exception. Looking further, not just the parsing but the whole scanner knows about this construct and hardcodes 0/1 or more dirs behaviour, so it would be a lot of work to change. --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1992,7 +1992,8 @@ point on. ) item(tt(c)var(N)tt(,)var(M))( The flag tt(LPAR()#c)var(N)tt(,)var(M)tt(RPAR()) can be used anywhere -that the tt(#) or tt(##) operators can be used; it cannot be combined +that the tt(#) or tt(##) operators can be used except in the expressions +`tt((*/)#)' and `tt((*/)##)'; it cannot be combined with other globbing flags and a bad pattern error occurs if it is misplaced. It is equivalent to the form tt({)var(N)tt(,)var(M)tt(}) in regular expressions. The previous character or group is required to While looking at Src/glob.c I also noticed that ? is ignored for globbing if it is preceded by a % at the start of a string, is that documented anywhere? bash doesn't have this behaviour, and emulate sh obviously doesn't help. /* If % is immediately followed by ?, then that ? is * * not treated as a wildcard. This is so you don't have * * to escape job references such as %?foo. */ if (str[0] == '%' && str[1] == Quest) str[1] = '?'; I would argue that if someone is too lazy to escape their job references they should just setopt nonomatch. I can imagine files like that existing if you downloaded some nonlatin filenames via http and they were saved percent-escaped, then you might want to find such files with %??%* or something, maybe? I know that at least I would be very confused if zsh then told me "no matches found", viz, % touch %ab%de % echo %??%* zsh: no matches found: %??%* % echo (#)%??%* %ab%de I sort of feel like an explicit option for this would be a bit awkward. -- Mikael Magnusson