From f99560817a75027a2f721349022cbc01ca1a607c Mon Sep 17 00:00:00 2001 From: "CORP\\mmrzik" Date: Fri, 5 Jan 2024 16:42:26 +0100 Subject: [PATCH] #1369: made "*" latest stable, and fixed mac bug --- documentation/functions.asciidoc | 5 ++--- scripts/src/main/resources/scripts/functions | 22 +++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/documentation/functions.asciidoc b/documentation/functions.asciidoc index df6fd5b9b..9e4c49405 100644 --- a/documentation/functions.asciidoc +++ b/documentation/functions.asciidoc @@ -339,10 +339,10 @@ Determines whether the actual version is contained in the security file for the === doCheckVersionRange Determines whether a version is in a version range. -=== doGetLatestSoftwareVersion +=== doGetAnyLatestSoftwareVersion Determines the latest available version of software and returns it. If a prefix is given, it will be taken into account. -=== doGetLatestStableSoftwareVersion +=== doGetLatestSoftwareVersion Determines the latest stable available version of software and returns it. If a prefix is given, it will be taken into account. === doGetNextVersion @@ -432,4 +432,3 @@ In this case, it does the handling to `list`, `get`, or `set` the version and ex If -- is passed, a variable is set that prevents further calls of this function and ends with the return value 0. If none of these options are passed, the return value is 255. - diff --git a/scripts/src/main/resources/scripts/functions b/scripts/src/main/resources/scripts/functions index cb93f9919..f4154565b 100755 --- a/scripts/src/main/resources/scripts/functions +++ b/scripts/src/main/resources/scripts/functions @@ -1300,12 +1300,12 @@ function doInstall() { if [ -z "${version}" ] then version=$(doGetLatestSoftwareVersion "${software}") - doDebug "Resolved latest version of ${software} to ${version}" + doDebug "Resolved latest stable version of ${software} to ${version}" elif [ "${version:${#version}-2}" = "*!" ] then doDebug "Resolving version prefix ${version}" edition=$(doGetSoftwareEdition "${software}") - resolved_version=$(doGetLatestStableSoftwareVersion "${software}" "${version}") + resolved_version=$(doGetAnyLatestSoftwareVersion "${software}" "${version}") if [ -n "${resolved_version}" ] then doDebug "Resolved version prefix ${version} to ${resolved_version}" @@ -1854,7 +1854,7 @@ function doGetSoftwareEdition() { # $1: software # $2: optional prefix -function doGetLatestSoftwareVersion() { +function doGetAnyLatestSoftwareVersion() { local software="${1}" local prefix="${2}" local edition @@ -1864,7 +1864,7 @@ function doGetLatestSoftwareVersion() { then version="$(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV | head -1)" else - prefix="${prefix:0:${#prefix}-1}" + prefix="${prefix:0:${#prefix}-2}" # 2 for "*!" prefix="${prefix/./[.]}" version="$(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV | head -1)" fi @@ -1873,18 +1873,24 @@ function doGetLatestSoftwareVersion() { # $1: software # $2: optional prefix -function doGetLatestStableSoftwareVersion() { +function doGetLatestSoftwareVersion() { local software="${1}" local prefix="${2}" local edition local version if [ -z "${prefix}" ] then - mapfile -t versions < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV) + versions=() + while IFS= read -r line; do + versions+=("$line") + done < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | sort -rV) else - prefix="${prefix:0:${#prefix}-2}" # 2 for "*!" + prefix="${prefix:0:${#prefix}-1}" # 1 for "*" prefix="${prefix/./[.]}" - mapfile -t versions < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV) + versions=() + while IFS= read -r line; do + versions+=("$line") + done < <(find "${DEVON_IDE_HOME}"/urls/"${software}"/"${edition}" -mindepth 1 -maxdepth 1 -print | awk -F'/' '{print $NF}' | grep "^${prefix}" | sort -rV) fi # version is not considered stable (see IDEasy VersionSegment) if: