Bash: compgen How to get rid of Warning message [option may not work as you expect]?

StackOverflow https://stackoverflow.com/questions/16930354

  •  31-05-2022
  •  | 
  •  

Question

I am making a simple bash completion program using compgen

however when using compgen -F option, the warning message keep prompt out and break my list of work

I am using Ubuntu 12.04. How can I get rid of this or debug it? Thanks

kithokit@09:54:25 ~ $ compgen -F a
bash: compgen: warning: -F option may not work as you expect
Was it helpful?

Solution 2

You can get rid of the warning like this:

compgen -F a 2>/dev/null

but unfortunately that will also discard any real error message from compgen.

As far as I can see from the bash source code, there is no other way to suppress the message, but I didn't look really deep.

OTHER TIPS

From man bash

compgen [option] [word]
Generate possible completion matches for word according to the options, which may be any option accepted by the complete builtin with the exception of -p and -r, and write the matches to the standard output. When using the -F or -C options, the various shell variables set by the programmable completion facilities, while available, will not have useful values.

As this shows, you probably have some variable set to alter the behaviour of the bash completion facilities and the option -F to compgen ignores those variables and values, informing you of this with the above warning.

References:
[1] http://linux.die.net/man/1/bash

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top