'have' keyword for bash completion 'have' keyword for bash completion bash bash

'have' keyword for bash completion


have and _have are just two functions defined in the base bash_completion file. Between the two, they form a wrapper around the built-in type command to determine if a particular command/program available.

# This function checks whether we have a given program on the system.#_have(){    # Completions for system administrator commands are installed as well in    # case completion is attempted via `sudo command ...'.    PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &>/dev/null}# Backwards compatibility for compat completions that use have().# @deprecated should no longer be used; generally not needed with dynamically#             loaded completions, and _have is suitable for runtime use.have(){    unset -v have    _have $1 && have=yes}