Skip to content

Instantly share code, notes, and snippets.

@igilham
Created February 22, 2018 12:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Prelude in bash scripts to declare installed command requirements
#!/bin/bash
# Declare requirements in bash scripts
set -e
function requires() {
if ! command -v $1 &>/dev/null; then
echo "Requires $1"
exit 1
fi
}
requires "jq"
requires "curl"
# etc.
# ... rest of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment