From 678fe9d204426c2175921fe03b23a2df75a1cf33 Mon Sep 17 00:00:00 2001 From: Michael Sesterhenn Date: Thu, 20 Jun 2024 13:07:44 -0500 Subject: [PATCH 1/2] Trim spaces around k and v in build.properties to be more forgiving. --- sbt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbt b/sbt index 7d3f707e8..2c1e72cf7 100755 --- a/sbt +++ b/sbt @@ -707,6 +707,9 @@ loadConfigFile() { } loadPropFile() { + # trim key and value so as to be more forgiving with spaces around the '=': + k=$(echo $k |sed -e 's/^\s*(.+)\s*$/\\1/g') + v=$(echo $v |sed -e 's/^\s*(.+)\s*$/\\1/g') while IFS='=' read -r k v; do if [[ "$k" == "sbt.version" ]]; then build_props_sbt_version="$v" From 087770f5e0451bcb71b6494cc8c2441ae3e00c9f Mon Sep 17 00:00:00 2001 From: Michael Sesterhenn Date: Fri, 21 Jun 2024 11:21:15 -0500 Subject: [PATCH 2/2] Use built-in bash string trimming instead of sed. --- sbt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sbt b/sbt index 2c1e72cf7..a73586c81 100755 --- a/sbt +++ b/sbt @@ -89,6 +89,14 @@ cygwinpath() { fi } +# Trim leading and trailing spaces from a string. +# Echos the new trimmed string. +trimString() { + local inputStr="$*" + local modStr="${inputStr#"${inputStr%%[![:space:]]*}"}" + modStr="${modStr%"${modStr##*[![:space:]]}"}" + echo "$modStr" +} declare -r sbt_bin_dir="$(dirname "$(realpathish "$0")")" declare -r sbt_home="$(dirname "$sbt_bin_dir")" @@ -708,8 +716,8 @@ loadConfigFile() { loadPropFile() { # trim key and value so as to be more forgiving with spaces around the '=': - k=$(echo $k |sed -e 's/^\s*(.+)\s*$/\\1/g') - v=$(echo $v |sed -e 's/^\s*(.+)\s*$/\\1/g') + k=$(trimString $k) + v=$(trimString $v) while IFS='=' read -r k v; do if [[ "$k" == "sbt.version" ]]; then build_props_sbt_version="$v"