compgen warning: -C option not working as I expected
4
votes
1
answer
1904
views
What is the correct way to use the
compgen -C
option?
I'm trying to learn about Bash programmable completion, and in particular the compgen
builtin function. I'm experimenting with the different compgen
command-line options, and I don't understand how the -C
flag is supposed to work. From the [GNU Bash Reference Manual](http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html) :
> -C command
>
>> command is executed in a subshell environment, and its output is used as the possible completions.
Based on this, I expect something like the following to work:
$ compgen -C 'echo "first_option second_option"' f
first_option
But instead, I get this:
$ compgen -C 'echo "first_option second_option"' f
-bash: compgen: warning: -C option may not work as you expect
first_option second_option f
I've tried this with Bash version 4.2.45 on OS X 10.7 and with Bash version 4.2.25 on Ubuntu 12.04, and in both cases I get the same error:
-bash: compgen: warning: -C option may not work as you expect
Asked by Curious Costanza
(41 rep)
Mar 3, 2014, 09:05 PM
Last activity: Oct 3, 2022, 01:14 PM
Last activity: Oct 3, 2022, 01:14 PM