From 087770f5e0451bcb71b6494cc8c2441ae3e00c9f Mon Sep 17 00:00:00 2001 From: Michael Sesterhenn Date: Fri, 21 Jun 2024 11:21:15 -0500 Subject: [PATCH] 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"