I'm trying to create a Bash completion script for a Java program. A typical invocation of that program might look like this:
$ javaProgram -Dproperty=foo option1 option2
Part of my script will be to suggest the various Java properties that are available for this program (i.e., when the user types -D
, the script would suggest, say, property=
, allowing the user to then type the value).
I'd like the completion to not insert a space after the equals sign. However, when the user is typing the various options for the program (option1
and option2
in the above example), I'd like the script to do the completion, and insert a space when it is completed.
I'm new to Bash completion scripting, but I'm aware of the nospace
option for the complete
shell builtin. It doesn't seem to work for the compgen
builtin, though, which seems like what I want. I've tried using nospace
, and then explicitly including spaces at the end of the appropriate options, but they don't seem to be making it through.
Does anyone know how to get spaces at the end of some options, but no spaces at the end of others?