Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Use of (e:...:) glob qualifier with _files -g?



On 4 Nov 2019, at 00:08, Chris Nebel <c.nebel@xxxxxxx> wrote:
> *(e:'file -bz $REPLY | grep -wq archive')

I'm not sure that's even a good idea. You'd be running an external process
against every single file the function encountered. On network drives or in
directories with many files that could take a while.

Also, i've never used darwinup, but it looks to me like it supports only a
select number of archive formats, which are guessed based on the file
extension and enumerated here:

https://github.com/macosforge/darwinbuild/blob/master/darwinup/Archive.cpp#L323

If that's the case, you should be able to just use '*.(tar|zip|whatever)',
which is much simpler and faster.

With that said, to answer your actual question, i think the reason it doesn't
work is that _files has an undocumented feature where if it detects unescaped
white space in the pattern it assumes that you're trying to supply *multiple*
patterns to be transformed into a brace expansion. Maybe there is some very
fancy quoting you can do to make that work, but at that point i think using
the + qualifier would be easier.

dana



Messages sorted by: Reverse Date, Date, Thread, Author