From 5135a1e58ade2bfafc8c1fda359540eafd72531e Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Tue, 21 Jan 2020 10:25:17 -0700 Subject: [PATCH] tests/core: Really pick C.UTF-8 locale The case-ignoring regex `^(C|en_US)` will match any locale that starts with `c`. On my system this is `ca_AD.utf8`, which breaks the test suite. Instead, use a single regex that includes the joining `.` rather than 2 separate regexes. This also changes `head` to use the `-n` option, which has been preferred for at least 10 years in the coreutils version and is supported by busybox as well. --- tests/libtest-core.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/libtest-core.sh b/tests/libtest-core.sh index 46aafab0..945d2857 100644 --- a/tests/libtest-core.sh +++ b/tests/libtest-core.sh @@ -41,7 +41,7 @@ assert_not_reached () { # If we can't find the locale command assume we have support for C.UTF-8 # (e.g. musl based systems) if type -p locale >/dev/null; then - export LC_ALL=$(locale -a | grep -Ee '\.(UTF-8|utf8)' | grep -iEe '^(C|en_US)' | head -1 || true) + export LC_ALL=$(locale -a | grep -iEe '^(C|en_US)\.(UTF-8|utf8)$' | head -n1 || true) if [ -z "${LC_ALL}" ]; then fatal "Can't find suitable UTF-8 locale"; fi else export LC_ALL=C.UTF-8