Change versionLessThan to work in strict mode (#1723)

This commit is contained in:
Geoff Bourne
2022-09-08 20:23:34 -05:00
committed by GitHub
parent d6de14123b
commit 4d3464f3f1
+13 -8
View File
@@ -11,10 +11,10 @@ function get_from_gh() {
log "ERROR: GH_TOKEN has permissions it doesn't need. Recreate or update this personal access token and disable ALL scopes." log "ERROR: GH_TOKEN has permissions it doesn't need. Recreate or update this personal access token and disable ALL scopes."
exit 1 exit 1
else else
echo $(curl -fsSL -H "Authorization: token $GH_TOKEN" ${@:2} $1) curl -fsSL -H "Authorization: token $GH_TOKEN" "${@:2}" "$1"
fi fi
else else
echo $(curl -fsSL ${@:2} $1) curl -fsSL "${@:2}" "$1"
fi fi
} }
@@ -50,7 +50,7 @@ function isValidFileURL() {
function resolveEffectiveUrl() { function resolveEffectiveUrl() {
url="${1:?Missing required url argument}" url="${1:?Missing required url argument}"
if ! curl -Ls -o /dev/null -w %{url_effective} "$url"; then if ! curl -Ls -o /dev/null -w "%{url_effective}" "$url"; then
log "ERROR failed to resolve effective URL from $url" log "ERROR failed to resolve effective URL from $url"
exit 2 exit 2
fi fi
@@ -184,11 +184,16 @@ function normalizeMemSize() {
} }
function versionLessThan() { function versionLessThan() {
mc-image-helper compare-versions "${VANILLA_VERSION}" lt "${1?}" # Use if-else since strict mode might be enabled
if mc-image-helper compare-versions "${VANILLA_VERSION}" lt "${1?}"; then
return 0
else
return 1
fi
} }
requireVar() { requireVar() {
if [ ! -v $1 ]; then if [ ! -v "$1" ]; then
log "ERROR: $1 is required to be set" log "ERROR: $1 is required to be set"
exit 1 exit 1
fi fi
@@ -202,8 +207,8 @@ requireEnum() {
var=${1?} var=${1?}
shift shift
for allowed in $*; do for allowed in "$@"; do
if [[ ${!var} = $allowed ]]; then if [[ ${!var} = "$allowed" ]]; then
return 0 return 0
fi fi
done done
@@ -301,7 +306,7 @@ function extract() {
} }
function getDistro() { function getDistro() {
cat /etc/os-release | grep -E "^ID=" | cut -d= -f2 | sed -e 's/"//g' grep -E "^ID=" /etc/os-release | cut -d= -f2 | sed -e 's/"//g'
} }
function checkSum() { function checkSum() {