Use built-in bash string trimming instead of sed.

This commit is contained in:
Michael Sesterhenn 2024-06-21 11:21:15 -05:00
parent 678fe9d204
commit 087770f5e0
1 changed files with 10 additions and 2 deletions

12
sbt
View File

@ -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"