Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Use of (e:...:) glob qualifier with _files -g?
- X-seq: zsh-users 24396
- From: Chris Nebel <c.nebel@xxxxxxx>
- To: zsh-users <zsh-users@xxxxxxx>
- Subject: Re: Use of (e:...:) glob qualifier with _files -g?
- Date: Mon, 4 Nov 2019 12:41:01 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1572900062; bh=BezjEIWVfEid5iaIHJg2Y/K1yHWgnrJBdEsuHGiWu3M=; h=From:Content-Type:Subject:Date:To:Message-Id; b=s22TeNUCTHFipBmz+3jqic0escd/zE1JI/cZl5M07gCPoaU0yozCRylGO1ubyWEuw swjfycPV6IzCM8chnbEb+f1zAXSHNqIZEOQGN08tAGvHkPvkZdJ6crYBdjLPqJjPNN TuBKefJNbQ79L0uhiCHuNnNlzMtLdQiV3zVhih+9EvklgAa8fpooJxuikyQUq8U7PW pP2+pCjkiGNWfNGD17Z4oojdWCwp6nLQK1avreZ/jG0gRi88k7itJNl4AJzsWt4Jkd UfVf+0m5tZGgwMf1eDSHdUQB1/WbNfgsce/Z+roxGjbYwJpQBZF03L2zWkTAHmDhSU aD0KKWtnigUJg==
- In-reply-to: <8F91689D-3069-4A1F-A4B2-3BF6F009B878@dana.is>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <206B06E5-8D28-4132-A0CC-BE070F9A5F7C@mac.com> <8F91689D-3069-4A1F-A4B2-3BF6F009B878@dana.is>
Ok, fair. I’ve been worried that while on the one hand I’d like to complete only supported archive files, on the other hand people use all sorts of mutant extensions for them, especially when compressed, hence just sniffing the file contents. However, a not-terribly-complicated pattern will cover a lot of the cases.
My problem then becomes how to let people configure the completion so they can use any extensions I didn’t cover. I’m guessing that the answer has something to do with zstyle and the “file-patterns” style, but I’m having trouble turning the examples in zshcompsys(1) into something that works. To make this a bit more concrete, say my completion code looks something like this:
files -g '*.(cpio|tar|xar)'
…and someone wants to also match “*.cpgz” files, what would they do?
—Chris N.
> On Nov 3, 2019, at 10:56 PM, dana <dana@xxxxxxx> wrote:
>
> 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