From 1b2c45f9d037aa17f2dfc4ccac08bb689e2ce003 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Fri, 23 Feb 2018 18:58:45 -0600 Subject: [PATCH] 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. --- scripts/remap.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/remap.sh b/scripts/remap.sh index e9817bcb4f..c64bcca87f 100755 --- a/scripts/remap.sh +++ b/scripts/remap.sh @@ -24,11 +24,16 @@ if [ ! -f "$jarpath.jar" ]; then fi # OS X & FreeBSD don't have md5sum, just md5 -r -if [[ "$OSTYPE" == "darwin"* || "$(uname)" == "FreeBSD" ]]; then - shopt -s expand_aliases - alias md5sum='md5 -r' - echo "Using an alias for md5sum on macOS and/or FreeBSD" -fi +command -v md5sum >/dev/null 2>&1 || { + command -v md5 >/dev/null 2>&1 && { + shopt -s expand_aliases + alias md5sum='md5 -r' + 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) if [ "$checksum" != "$minecrafthash" ]; then