Last active
October 22, 2018 04:19
-
-
Save atika/d3fcd489cfc3e6e61321 to your computer and use it in GitHub Desktop.
Verify if programs exits on system before executing a shell script
This file contains hidden or 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
verify_programs() { | |
local programs="$1" | |
local ccyan="\\033[1;36m" | |
local cnormal="\\0033[0;39m" | |
abort=0 | |
for p in $programs; do | |
type $p >/dev/null 2>&1 || { echo -e >&2 " ${ccyan}${p}${cnormal} required but it's not installed. Aborting."; abort=1; } | |
done | |
if [[ $abort -eq 1 ]]; then | |
exit 1; | |
fi | |
} | |
verify_programs "mutt mysql vi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment