How to check if a program is available

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2023-03-28

Use command -v in an if statement

#!/usr/bin/env bash
if command -v rg; then
  rg ...
  echo "Dependencies: ripgrep missing"
  echo "(on macos): brew install ripgrep"