Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
(#cN,M) error, %? doesn't glob
- X-seq: zsh-workers 29504
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: (#cN,M) error, %? doesn't glob
- Date: Fri, 24 Jun 2011 04:00:43 +0200
- 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=
- 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
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author