From fe1fb757481f36233f3ad30bb394555c1ca4c488 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 18 Jan 2021 21:09:30 +0100 Subject: [PATCH] make _round_float more LANG independent (C not installed) --- bashbot.sh | 5 +++-- doc/7_develop.md | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index a3a9958..e6fe4c3 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.30-0-g3266427 +#### $$VERSION$$ v1.31-dev-0-gad532cc ################################################################## # emmbeded system may claim bash but it is not @@ -89,7 +89,8 @@ _is_function() { # if $2 is not given or is not a positive number zero is assumed _round_float() { local digit="$2"; [[ "$2" =~ ^[${o9o9o9}]+$ ]] || digit="0" - { LC_ALL=C.utf-8 printf "%.${digit}f" "$1"; } 2>/dev/null + : "$(LC_ALL=C printf "%.${digit}f" "$1" 2>/dev/null)" + printf "%s" "${_//,/.}" # make more LANG independent } # date is external, printf is much faster _date(){ diff --git a/doc/7_develop.md b/doc/7_develop.md index ec96dc5..ddfea3e 100644 --- a/doc/7_develop.md +++ b/doc/7_develop.md @@ -284,8 +284,9 @@ bar="${_/__x/_c}" # a_b_c : ${SOMEVAR} # "String in var" $_ -> "var" : $(<"file") # "Content of\n file" $_ -> "file" -# pitfall test command -[ -n "$MYVAR" ] && echo "$_" # outputs "]" +# pitfall [ vs. test command +[ -n "xxx" ] && echo "$_" # $_ -> "]" +test -n "xxx" && echo "$_" # $_ -> "xxx" # pitfall command substitution: globbing and IFS is applied! : "$(echo "a* is born")"# $_ -> a* is globbed even quoted! @@ -386,5 +387,5 @@ fi #### [Prev Function Reference](6_reference.md) -#### $$VERSION$$ v1.30-0-g3266427 +#### $$VERSION$$ v1.31-dev-0-gad532cc