mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-27 12:42:40 +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
|
||||
# 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(){
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user