Last active
March 29, 2020 12:47
-
-
Save nikkej/9bc25e3bd2f22680e55cbb8c01a50660 to your computer and use it in GitHub Desktop.
A simple bash function to test existence of required programs
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 | |
# | |
# Simple bash function to test existence of required programs for script | |
# to work properly. Utilizes bash array | |
# | |
function check_pre_reqs { | |
declare -a procrams=($*) | |
for item in ${procrams[*]}; do | |
if test "$(type -p $item)" == ""; then | |
proc_names="$proc_names $item" | |
fi | |
done | |
if test "$proc_names" != ""; then | |
echo "Script requires following programs to work:$proc_names" | |
exit 1 | |
fi | |
} | |
check_pre_reqs "awk" "cabextract" "fooz" "git" "ilspycmd" "msiextract" "xmllint" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment