mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-28 04:45:00 +00:00
make _round_float more LANG independent (C not installed)
This commit is contained in:
parent
ad532cce54
commit
fe1fb75748
@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
|
|||||||
# 8 - curl/wget missing
|
# 8 - curl/wget missing
|
||||||
# 10 - not bash!
|
# 10 - not bash!
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v1.30-0-g3266427
|
#### $$VERSION$$ v1.31-dev-0-gad532cc
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# emmbeded system may claim bash but it is not
|
# 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
|
# if $2 is not given or is not a positive number zero is assumed
|
||||||
_round_float() {
|
_round_float() {
|
||||||
local digit="$2"; [[ "$2" =~ ^[${o9o9o9}]+$ ]] || digit="0"
|
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 is external, printf is much faster
|
||||||
_date(){
|
_date(){
|
||||||
|
@ -284,8 +284,9 @@ bar="${_/__x/_c}" # a_b_c
|
|||||||
: ${SOMEVAR} # "String in var" $_ -> "var"
|
: ${SOMEVAR} # "String in var" $_ -> "var"
|
||||||
: $(<"file") # "Content of\n file" $_ -> "file"
|
: $(<"file") # "Content of\n file" $_ -> "file"
|
||||||
|
|
||||||
# pitfall test command
|
# pitfall [ vs. test command
|
||||||
[ -n "$MYVAR" ] && echo "$_" # outputs "]"
|
[ -n "xxx" ] && echo "$_" # $_ -> "]"
|
||||||
|
test -n "xxx" && echo "$_" # $_ -> "xxx"
|
||||||
|
|
||||||
# pitfall command substitution: globbing and IFS is applied!
|
# pitfall command substitution: globbing and IFS is applied!
|
||||||
: "$(echo "a* is born")"# $_ -> a* is globbed even quoted!
|
: "$(echo "a* is born")"# $_ -> a* is globbed even quoted!
|
||||||
@ -386,5 +387,5 @@ fi
|
|||||||
|
|
||||||
#### [Prev Function Reference](6_reference.md)
|
#### [Prev Function Reference](6_reference.md)
|
||||||
|
|
||||||
#### $$VERSION$$ v1.30-0-g3266427
|
#### $$VERSION$$ v1.31-dev-0-gad532cc
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user