Make tests detect UTF-8 locale with a helper executable

This uses the same utility function that mosh-client/mosh-server do.
This resolves portability issues with the 'locale' command.
This fixes OpenBSD 6.0 and probably Haiku builds.
This commit is contained in:
John Hood
2017-03-20 10:49:16 -04:00
parent 0f0301b746
commit 654f269917
5 changed files with 62 additions and 13 deletions
+2 -4
View File
@@ -60,14 +60,12 @@ chr()
set_locale()
{
# Test for a usable locale.
map=$(locale charmap 2>/dev/null)
if [ "$map" = "utf-8" ] || [ "$map" = "UTF-8" ]; then
if ./is-utf8-locale 2> /dev/null; then
return 0
fi
# Attempt to find/set a usable locale.
for i in en_US.UTF-8 en_US.utf8 C.UTF-8; do
map="$(env LANG=$i locale charmap 2>/dev/null)"
if [ "$map" = "utf-8" ] || [ "$map" = "UTF-8" ]; then
if env LANG=$i ./is-utf8-locale 2> /dev/null; then
export LANG=$i LC_ALL=''
return 0
fi