Use a more general method of aliasing md5sum

Rather than checking the platform or operating system, simply check if
the command exists. If the check fails, check if the md5 command exists.
If that fails as well, cancel the build script. Otherwise, assign the
alias as before.
This commit is contained in:
Kyle Wood 2018-02-23 18:58:45 -06:00
parent d39553c217
commit b2eb1e7f00

View file

@ -24,11 +24,16 @@ if [ ! -f "$jarpath.jar" ]; then
fi fi
# OS X & FreeBSD don't have md5sum, just md5 -r # OS X & FreeBSD don't have md5sum, just md5 -r
if [[ "$OSTYPE" == "darwin"* || "$(uname)" == "FreeBSD" ]]; then command -v md5sum >/dev/null 2>&1 || {
shopt -s expand_aliases command -v md5 >/dev/null 2>&1 && {
alias md5sum='md5 -r' shopt -s expand_aliases
echo "Using an alias for md5sum on macOS and/or FreeBSD" alias md5sum='md5 -r'
fi echo "md5sum command not found, using an alias instead"
} || {
echo >&2 "No md5sum or md5 command found"
exit 1
}
}
checksum=$(md5sum "$jarpath.jar" | cut -d ' ' -f 1) checksum=$(md5sum "$jarpath.jar" | cut -d ' ' -f 1)
if [ "$checksum" != "$minecrafthash" ]; then if [ "$checksum" != "$minecrafthash" ]; then