Command_exists

Testing a command exists

Method 1

if command -v jq > /dev/null; then
  JQ_EXISTS=t
else
  JQ_EXISTS=f
  return 1
fi

Method 2

command -v figlet > /dev/null 2>&1
[ "$?" = 0 ] || __exit_with_message "ERR" "Figlet missing"
Previous
Next