Skip to content

Check a Named Command is on PATH

Return success if the named variable holds a command that command -v can find on PATH.

Language: Shell

Added on: 19th August 2026

check_executable() {
  local cmd_name=$1

  command -v "${!cmd_name-}" &>/dev/null
}

Caveats

Pass the variable name that stores the command, not the command itself.