1
0
mirror of https://github.com/jaygooby/ttfb.sh synced 2025-12-10 16:07:22 +01:00

Ensure curl uses period separators for floating point values

`bc` requires these to do calculations; it can't use locale separators
like `,`

https://en.wikipedia.org/wiki/Decimal_separator#Countries_using_decimal_comma
This commit is contained in:
Jay Caines-Gooby
2020-06-26 10:22:53 +01:00
parent c8088c7f63
commit 7243614da2

8
ttfb
View File

@@ -65,6 +65,14 @@ for dependency in curl bc column; do
which -s $dependency || (echo "You need to have '$dependency' installed and in your \$PATH" >&2 && exit 1)
done
# Ensure curl uses period separators for floating point values, which
# bc requires to do calculations (i.e. it can't use locale separators like ,)
if (locale -a | egrep ^C.UTF-8$); then
export LC_ALL=C.UTF-8
else
export LC_ALL=C
fi
# Cribbed from https://stackoverflow.com/a/41762669/391826
median() {
arr=($(printf '%s\n' "${@}" | sort -n))