Is have a keyword in bash? Or do bash completion scripts use a language that is not bash?
have gcc &&
_gcc()
{
It is common. See: grep "have .* &&" /etc/bash_completion.d/*
I could not find any information on the bash completion tutorials I’ve seen and I could not find any information in man bash. It’s also difficult to google “have”. Where do I find documentation on this?
I’m guessing it has to do with making sure that there gcc exists in the PATH?
edit: yes. /etc/bash_completion contains:
have()
{
unset -v have
# Completions for system administrator commands are installed as well in
# case completion is attempted via `sudo command ...'.
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
have="yes"
}
haveand_haveare just two functions defined in the basebash_completionfile. Between the two, they form a wrapper around the built-intypecommand to determine if a particular command/program available.