zsh-workers
 help / color / mirror / code / Atom feed
* [bug] Completion functions _files/_path_files -F filter on escaped file names
@ 2023-06-21 19:29 Johan Grande
  2023-06-22  3:54 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Grande @ 2023-06-21 19:29 UTC (permalink / raw)
  To: zsh-workers

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-20  5:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-21 19:29 [bug] Completion functions _files/_path_files -F filter on escaped file names Johan Grande
2023-06-22  3:54 ` Bart Schaefer
2023-06-24 19:55   ` Johan Grande
2023-07-20  5:15     ` 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).