-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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: handle Linux systems with no 'locale' #8324
brew.sh: handle Linux systems with no 'locale' #8324
Conversation
such as Alpine Linux Closes Linuxbrew/docker#83
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.
Use command -v
rather than which
.
Co-authored-by: Shaun Jackman <sjackman@gmail.com>
Let me know which commit to keep:
|
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.
👏🏻 Easy! Thanks again!
Library/Homebrew/brew.sh
Outdated
then | ||
export LC_ALL=C | ||
elif [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] | ||
if [[ "$(locale charmap 2>/dev/null)" != "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.
I'm not a fan of suppressing all error messages from locale
in this way.
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.
Do you suggest removing 2>/dev/null 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.
Can you explain why @sjackman? When we're just using the output to decide on a variable and we have an else
: what's the upside of showing errors 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.
For troubleshooting. We do not expect locale
to fail, and if it were to fail for some unexpected reason, and the user were to report an issue, we would have no basis on which to troubleshoot that failure, because stderr was unconditionally suppressed, which is the shell equivalent of catching all exceptions and ignoring them.
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.
We're not checking the exit code of locale
as-is just checking (twice) if the output contains a string. It doesn't matter to us whether the output doesn't contain that string due to a failure or due to the locale being missing. Considering how we've been printing these warnings at users in the past and causing unnecessary confusion: I'd rather we didn't continue to do so.
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.
We have a difference of opinion here, and that's okay. I prefer not to suppress stderr, but I'm fine merging either.
9abe3ee
to
bab43d4
Compare
Co-authored-by: Shaun Jackman <sjackman@gmail.com>
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.
Thank you, Maxim!
Library/Homebrew/brew.sh
Outdated
if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]] | ||
if ! command -v locale >/dev/null | ||
then | ||
export LC_ALL=C |
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.
This isn't correct behaviour on macOS, unfortunately.
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.
Under what circumstances does command -v locale
fail on macOS? I believe that situation is impossible with SIP enabled.
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.
It is hence I'd like to avoid the check.
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 can rewrite this part using if [[ -n "$HOMEBREW_MACOS" ]]; then ... else ... {complex logic}; fi
-- would that work?
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.
Yeh, go for it. I'm still of the belief that checking for locale
is pointless where we're correctly handling the case when it doesn't exist anyway if we hide the errors.
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'll defer to @sjackman on Linux behaviour but macOS needs to be the same as before.
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.
Looks great! Thank you, Maxim.
Thank you both! |
such as Alpine Linux
Closes Linuxbrew/docker#83
brew style
with your changes locally?brew tests
with your changes locally?