Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions scripts/start-utils
Original file line number Diff line number Diff line change
Expand Up @@ -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."
exit 1
else
echo $(curl -fsSL -H "Authorization: token $GH_TOKEN" ${@:2} $1)
curl -fsSL -H "Authorization: token $GH_TOKEN" "${@:2}" "$1"
fi
else
echo $(curl -fsSL ${@:2} $1)
curl -fsSL "${@:2}" "$1"
fi
}

Expand Down Expand Up @@ -50,7 +50,7 @@ function isValidFileURL() {

function resolveEffectiveUrl() {
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"
exit 2
fi
Expand Down Expand Up @@ -184,11 +184,16 @@ function normalizeMemSize() {
}

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() {
if [ ! -v $1 ]; then
if [ ! -v "$1" ]; then
log "ERROR: $1 is required to be set"
exit 1
fi
Expand All @@ -202,8 +207,8 @@ requireEnum() {
var=${1?}
shift

for allowed in $*; do
if [[ ${!var} = $allowed ]]; then
for allowed in "$@"; do
if [[ ${!var} = "$allowed" ]]; then
return 0
fi
done
Expand Down Expand Up @@ -301,7 +306,7 @@ function extract() {
}

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() {
Expand Down