Last active
July 15, 2024 11:41
-
-
Save montanaflynn/e1e754784749fd2aaca7 to your computer and use it in GitHub Desktop.
Checking for dependencies in 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
# Easy way to check for dependencies | |
checkfor () { | |
command -v $1 >/dev/null 2>&1 || { | |
echo >&2 "$1 required"; | |
exit 1; | |
} | |
} | |
checkfor "ffmpeg" | |
# example using an array of dependencies | |
array=( "convert" "ffmpeg" ) | |
for i in "${array[@]}" | |
do | |
command -v $i >/dev/null 2>&1 || { | |
echo >&2 "$i required"; | |
exit 1; | |
} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In line 16 it should be $i