Created
February 22, 2018 12:08
-
-
Save igilham/bb3d01441f8d9d72960a9e742656079e to your computer and use it in GitHub Desktop.
Prelude in bash scripts to declare installed command requirements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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