From ecbe2213e4ee19bb1b2ce434a7f9f0a2e56fa4dc Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 12 Aug 2020 21:08:14 +0000 Subject: [PATCH 1/4] brew.sh: handle systems with no 'locale' such as Alpine Linux Closes Linuxbrew/docker#83 --- Library/Homebrew/brew.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index b958c9e1ab..a04c3e2ba6 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,7 +6,10 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] +if ! which locale &>/dev/null +then + export LC_ALL=C +elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] then if [[ -n "$HOMEBREW_MACOS" ]] then From bab43d4cc8b828736a91565e5787dbbc5064ea7c Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 13 Aug 2020 06:59:39 -0500 Subject: [PATCH 2/4] brew.sh: use 'command -v' instead of 'which' Co-authored-by: Shaun Jackman --- Library/Homebrew/brew.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index a04c3e2ba6..9af5397792 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,7 +6,7 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if ! which locale &>/dev/null +if ! command -v locale >/dev/null then export LC_ALL=C elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] From d33691dcdb6f986dd970265d0018b4ecaa16f0b9 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 13 Aug 2020 17:08:06 -0500 Subject: [PATCH 3/4] brew.sh: don't suppress stderr for 'locale charmap' Co-authored-by: Shaun Jackman --- Library/Homebrew/brew.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 9af5397792..f985c3b7aa 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -9,7 +9,7 @@ esac if ! command -v locale >/dev/null then export LC_ALL=C -elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] +elif [[ "$(locale charmap)" != "UTF-8" ]] then if [[ -n "$HOMEBREW_MACOS" ]] then From b8d21dcf6008dafa4e9e9c2e1c56e5e1c057e1d2 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 17 Aug 2020 15:24:18 +0000 Subject: [PATCH 4/4] brew.sh: handle Linux systems with no 'locale' --- Library/Homebrew/brew.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index f985c3b7aa..59616772a1 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -6,15 +6,18 @@ case "$HOMEBREW_SYSTEM" in esac # Force UTF-8 to avoid encoding issues for users with broken locale settings. -if ! command -v locale >/dev/null +if [[ -n "$HOMEBREW_MACOS" ]] then - export LC_ALL=C -elif [[ "$(locale charmap)" != "UTF-8" ]] -then - if [[ -n "$HOMEBREW_MACOS" ]] + if [[ "$(locale charmap)" != "UTF-8" ]] then export LC_ALL="en_US.UTF-8" - else + fi +else + if ! command -v locale >/dev/null + then + export LC_ALL=C + elif [[ "$(locale charmap)" != "UTF-8" ]] + then locales=$(locale -a) c_utf_regex='\bC\.(utf8|UTF-8)\b' en_us_regex='\ben_US\.(utf8|UTF-8)\b'