2023年4月18日(火) 0:59 Chet Ramey <chet.ra...@case.edu>:
> Once you have -V, isn't -z superfluous? It's just
>
> compgen -V varname options word
> printf '%s\0' "${varname[@]}"
>
> right? What am I missing?

You are right. Actually, when I implemented -z, I also initially
thought about the possibility to add an option to store results in a
specified array. Then, after looking at the codebase of
bash-completion and thinking about the actual use cases, I decided to
switch to the flag -z, but I actually don't remember the exact reason
I finally switched to -z. (Maybe it was because when I submit a patch
to bash-completion, it is easier to explain the code using mapfile,
which is already used in bash-completion, than using printf '%s\0',
which the maintainer might not be comfortable with).

I thought about it again and I now feel -V is better if one needs to
choose one from -V and -z.

--
Koichi

Reply via email to