aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Afanasjew2015-12-22 01:42:33 +0100
committerMartin Afanasjew2015-12-23 06:54:11 +0100
commit8d3f33de905f5cecf9cac77447e7492e59734c5b (patch)
treea8cec98458846b9ed3165d91c52a970edd7d2ef3
parent8e4fad89691840d19e87a099e36ad474d9de54b0 (diff)
downloadbrew-8d3f33de905f5cecf9cac77447e7492e59734c5b.tar.bz2
bin/brew: enforce UTF-8 locale
Everyone should be using a UTF-8 locale nowadays. Not using one causes issues like `brew doctor` failing while checking symbolic links that point at file names with non-ASCII characters, since OS X always uses Unicode for the file system. Rely on `locale charmap` to detect the currently selected encoding and if that's not UTF-8, override the user's choice (if any) by setting `LC_ALL` to `en_US.UTF-8`, the assumption being that every system has a usable `en_US.UTF-8` locale installed. Fixes Homebrew/homebrew#44744. Closes Homebrew/homebrew#47247. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
-rwxr-xr-xbin/brew7
1 files changed, 7 insertions, 0 deletions
diff --git a/bin/brew b/bin/brew
index 9cdeb1a10..0503abc09 100755
--- a/bin/brew
+++ b/bin/brew
@@ -1,8 +1,15 @@
#!/bin/sh
+
chdir() {
cd "$@" >/dev/null
}
+# Force UTF-8 to avoid encoding issues for users with broken locale settings.
+if [ "$(locale charmap 2> /dev/null)" != "UTF-8" ]
+then
+ export LC_ALL="en_US.UTF-8"
+fi
+
BREW_FILE_DIRECTORY="$(chdir "${0%/*}" && pwd -P)"
HOMEBREW_BREW_FILE="$BREW_FILE_DIRECTORY/${0##*/}"