* Short-circuiting array-subscript glob qualifier?
@ 2005-05-03 14:26 Shawn Halpenny
2005-05-03 16:29 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Shawn Halpenny @ 2005-05-03 14:26 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]
Let's say I have a directory /foo/bar that contains a large number of files
and subdirectories. When I do this:
echo /foo/bar/**/^*,v(.[1,3])
I want it to echo the first three matching non-,v plain files.
Unfortunately, zsh still retrieves all filenames that match the glob. How
possible is it to have the glob stop as soon as the first 3 matches are
found? I realize that other qualifiers could affect this (for example, if
you wanted the last 3, clearly, the whole glob has to be completed; if you
used 'o' or 'O' to sort, you might still have to glob everything). Perhaps
this isn't worth the effort or is quite difficult, but it's sure handy for
large directories wherein you only need a well-defined subset of the files
that isn't controlled solely by the glob expression.
--
Shawn Halpenny
[-- Attachment #2: Type: text/html, Size: 879 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Short-circuiting array-subscript glob qualifier?
2005-05-03 14:26 Short-circuiting array-subscript glob qualifier? Shawn Halpenny
@ 2005-05-03 16:29 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2005-05-03 16:29 UTC (permalink / raw)
To: zsh-users
On May 3, 10:26am, Shawn Halpenny wrote:
}
} echo /foo/bar/**/^*,v(.[1,3])
}
} I want it to echo the first three matching non-,v plain files.
} Unfortunately, zsh still retrieves all filenames that match the glob.
Yep, that's right. All qualifiers that work on the file names (rather
than on the filesystem attributes) are applied once to the entire list
after the glob is done. Well, that's not quite right -- expressions
evaluated with (e:...:) are applied to each file as it is found, too,
but there's no provision for that to short-circuit the entire glob.
} How possible is it to have the glob stop as soon as the first 3
} matches are found?
Can't be done using glob patterns.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-03 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-03 14:26 Short-circuiting array-subscript glob qualifier? Shawn Halpenny
2005-05-03 16:29 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).