Repository navigation
Add fallback for hostname if uname isn't available. - #12655
Conversation
| def system_hostname | ||
| # Most platforms implement this POSIX standard: | ||
| `uname -n`.strip | ||
| rescue |
There was a problem hiding this comment.
This is not good because it relies on deep implementation details of backticks, which might vary between platforms and Ruby implementations.
Specifically, it relies on uname -n to use no shell, because if it used a shell it wouldn't raise an exception and just emit some stderr output + exit code 1.
It's best to not rely on deep implementation details like that in ruby/spec.
And anyway the real meaningful condition is POSIX vs not POSIX here, not try and rescue.
So it should use platform_is/platform_is_not :windows guards as I wrote you on Slack.
Also this is the second time you merge a PR and only ask for reviews after, this is uncomfortable and time-wasting so for the next PR wait for my review before merging.
There was a problem hiding this comment.
And anyway the real meaningful condition is POSIX vs not POSIX here, not try and rescue.
So it should use
platform_is/platform_is_not :windowsguards as I wrote you on Slack.
Why there isn't platform_is :posix?
There was a problem hiding this comment.
Why there isn't
platform_is :posix?
platform_is :posix sounds nice but platform_is_not :posix seems not so clear, e.g. there might be platforms which are not POSIX and are not Windows (although I don't think we support any of those).
|
@Segaja Could you explain the rationale for these changes? Please answer my questions at https://bugs.ruby-lang.org/issues/21095#note-7 |
cc @Segaja