-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
brew.sh: fixes for UTF-8 #8072
brew.sh: fixes for UTF-8 #8072
Conversation
|
Yeh, my bad -- I noticed that but had to leave and left the PR without a note that I'll continue working on it. |
Ready for a second review. |
Library/Homebrew/brew.sh
Outdated
then | ||
export LC_ALL=C | ||
else | ||
echo "Warning: Could not find usable locale." >&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the action item for the user here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm wondering if this should be not output or be a hard-stop error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
install either a UTF-8 locale of choice or C locale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, yeh, I'd make this an odie
with instructions on how to resolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good to me but I'd like to run this by @sjackman 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user is pretty much guaranteed to have a C
locale. If they do not, the world is burning. It's more likely that locale
failed to run (they don't have this executable in their PATH
, which itself is pretty unlikely) than they don't have a C
locale. Rather than emit a warning or error in this else
case, I'd just set LC_ALL=C
and move on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than emit a warning or error in this
else
case, I'd just setLC_ALL=C
and move on.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove c_regex
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
Library/Homebrew/brew.sh
Outdated
c_utf_regex='\bC\.(utf|UTF-)8' | ||
en_us_regex='en_US\.(utf|UTF-)8' | ||
utf_regex='[a-z][a-z]_[A-Z][A-Z]\.(utf|UTF-)8' | ||
c_regex='\bC\b' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_utf_regex='\bC\.(utf|UTF-)8' | |
en_us_regex='en_US\.(utf|UTF-)8' | |
utf_regex='[a-z][a-z]_[A-Z][A-Z]\.(utf|UTF-)8' | |
c_regex='\bC\b' | |
c_utf_regex='^C\.(utf8|UTF-8)$' | |
en_us_regex='^en_US\.(utf8|UTF-8)$' | |
utf_regex='^[a-z][a-z]_[A-Z][A-Z]\.(utf8|UTF-8)$' | |
c_regex='^C$' |
For style more than correctness. ^…$
is more common and easier to read than \b
. Anchor all patterns for consistency. Super minor but I found (utf8|UTF-8)
easier to read than (utf|UTF-)8
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^...$
don't work as one may expect because ^
and $
match the beginning and end of locale -a
rather than the beginning and end of each word.
# In Homebrew/brew Docker image
$ locale -a
C
C.UTF-8
POSIX
en_US.utf8
$ locales=$(locale -a)
$ c_utf_regex='\bC\.(utf8|UTF-8)\b'
$ [[ $locales =~ $c_utf_regex ]] && echo ${BASH_REMATCH[0]}
C.UTF-8
$ c_utf_regex='^C\.(utf8|UTF-8)$'
$ [[ $locales =~ $c_utf_regex ]] && echo ${BASH_REMATCH[0]}
# nothing is printed; return status == 1
Anchor all patterns for consistency.
OK to use \b
?
Super minor but I found (utf8|UTF-8) easier to read than (utf|UTF-)8.
OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK to use \b?
Yep! Thanks for the explanation.
Thank you for this PR, Maxim! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Maxim!
Thanks for the reviews, @MikeMcQuaid and @sjackman! |
brew style
with your changes locally?brew tests
with your changes locally?Fix Homebrew detection mechanism of usable locale.
Order of locales #8047 (comment):