Merge pull request #8324 from maxim-belkin/no-locale-no-problemo

brew.sh: handle Linux systems with no 'locale'
This commit is contained in:
Maxim Belkin 2020-08-17 11:16:38 -05:00 committed by GitHub
commit a72c9717cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,12 +6,18 @@ case "$HOMEBREW_SYSTEM" in
esac esac
# Force UTF-8 to avoid encoding issues for users with broken locale settings. # Force UTF-8 to avoid encoding issues for users with broken locale settings.
if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]]
then
if [[ -n "$HOMEBREW_MACOS" ]] if [[ -n "$HOMEBREW_MACOS" ]]
then
if [[ "$(locale charmap)" != "UTF-8" ]]
then then
export LC_ALL="en_US.UTF-8" export LC_ALL="en_US.UTF-8"
fi
else else
if ! command -v locale >/dev/null
then
export LC_ALL=C
elif [[ "$(locale charmap)" != "UTF-8" ]]
then
locales=$(locale -a) locales=$(locale -a)
c_utf_regex='\bC\.(utf8|UTF-8)\b' c_utf_regex='\bC\.(utf8|UTF-8)\b'
en_us_regex='\ben_US\.(utf8|UTF-8)\b' en_us_regex='\ben_US\.(utf8|UTF-8)\b'