From 7243614da2c44dfb08f42f54ceb083cf13d86d88 Mon Sep 17 00:00:00 2001 From: Jay Caines-Gooby Date: Fri, 26 Jun 2020 10:22:53 +0100 Subject: [PATCH] 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 --- ttfb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ttfb b/ttfb index 0f9e49c..e5a84c9 100755 --- a/ttfb +++ b/ttfb @@ -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))