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. |
There was a problem hiding this comment.
What's the action item for the user here?
There was a problem hiding this comment.
(I'm wondering if this should be not output or be a hard-stop error).
There was a problem hiding this comment.
install either a UTF-8 locale of choice or C locale.
There was a problem hiding this comment.
In that case, yeh, I'd make this an odie with instructions on how to resolve.
There was a problem hiding this comment.
sounds good to me but I'd like to run this by @sjackman 👀
There was a problem hiding this comment.
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.
Rather than emit a warning or error in this
elsecase, I'd just setLC_ALL=Cand move on.
OK
There was a problem hiding this comment.
Shall we remove c_regex then?
There was a problem hiding this comment.
| 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.
^...$ 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 == 1Anchor 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.
OK to use \b?
Yep! Thanks for the explanation.
|
Thank you for this PR, Maxim! |
|
Thanks for the reviews, @MikeMcQuaid and @sjackman! |
brew stylewith your changes locally?brew testswith your changes locally?Fix Homebrew detection mechanism of usable locale.
Order of locales #8047 (comment):