Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: qpdf or bashcompinit completion bug
2025-08-19 13:47:51 +0200, Vincent Lefevre:
> On 2025-08-19 06:33:53 +0100, Stephane Chazelas wrote:
> > 2025-08-18 22:12:46 +0200, Vincent Lefevre:
> > [...]
> > > I would not expect IFS to have changed to a non-standard value for
> > > the completion functions. Or should these functions be written in
> > > such a way they should work for any IFS value?
> > [...]
> >
> > IFS is set by users when they want to split things using $(...)
> > or $=var of read.
>
> But this does not seem to affect the completion system. If I change
> IFS in my shell and change a completer to output IFS (as hex), then
> it is the standard IFS value that is output, not the value I have
> set in the shell.
Looks like _main_complete has:
local IFS=$' \t\n\0'
So that's what will be used whenever unquoted $(...) or $=var
are used in the completion system (and IFS is not redefined).
> > But here in any case, the output of qpdf --zsh-completion is
> > intended to be evaluated as is, not split, with the default
> > value of IFS or otherwise, do doing that splitting (leaving
> > $(...) unquoted) is wrong.
>
> Yes, quoting is much better. But the result is the same as long as
> the eval'ed command does not generate tabs, newlines or significant
> sequences of spaces.
[...]
Which we can't guarantee for external commands. That code should
still be fixed by adding the $(...) as splitting doesn't make
sense, even if that's not causing any problem with current
versions of qpdf..
I see compgen in bashcompinit does:
C) results+=( $(eval $OPTARG) ) ;;
To split the output of the completion command, so splitting on
space, tab, newline, null while bash seems to be splitting on
newline only, so there should probably be a local IFS=$'\n'
there.
I beleive bash completion can't deal with newline characters at
all btw. Assumes things that are completed cannot contain
newlines (and of course not NULs either, but NULs are
unsupported throughout there, not just in completion).
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author