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

[bug] Completion functions _files/_path_files -F filter on escaped file names



Hello maintainers,

I just recently started writing completion functions and I'm bringing to you what I think is a bug:

% cat ~/.zshrc
% zsh --version
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

% foo() { echo "$@"; };
% _foo() { local exclusions=('*a *'); _path_files -F exclusions; }
% compdef _foo foo
% touch a 'a a' b
% foo <tab>
a     a\ a  b
% foo '<tab>
a  b

When completion with _files or _path_files is called at the beginning of an argument, exclusion patterns given with `-F` are applied to already-escaped file names. This breaks patterns that contain escapable characters such as a space or [].

With a \ added to the pattern, 'a a' is filtered out.

% _foo() { local exclusions=('*a\ *'); _path_files -F exclusions; }
% compdef _foo foo
% foo <tab>
a  b

But this is very brittle as it depends on the implementation of the escaping instead of the file names themselves.

My use case is a tool that works on TagSpaces tags, i.e., space-separated tags surrounded by brackets in file names such as IMG-2653[vacation alps].jpg. I want to offer, as completion, files that have or don't have a certain tag.

Do you think that this behavior could be fixed?

I appreciate the work you do in maintaining zsh which I use as my daily shell.

Cheers

--
Johan Grande





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