-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Prefer uname -n over hostname.
#12647
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
Conversation
| describe "Socket.gethostname" do | ||
| it "returns the host name" do | ||
| Socket.gethostname.should == `hostname`.strip | ||
| Socket.gethostname.should == `uname -n`.strip |
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 will break on pure Windows (GitHub Actions have msys).
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.
Maybe we can have a conditional on Windows to use hostname?
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.
Yes it would be good to avoid using uname on Windows as it might not be there/it's not the right thing to use.
You can use platform_is :windows do for that
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 revert this, hostname is more portable, and Arch can add a dependency to inetutils to run specs
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.
hostname is not more portable, it is a GNU-specific tool (inettools) and uname -n is standardised by POSIX/Open Group: https://pubs.opengroup.org/onlinepubs/009695399/utilities/uname.html and should be available everywhere. However, I accept on vanilla Windows, only hostname.exe exists.
|
Rather than reverting this, I am okay to add a fallback to |
See https://gitlab.archlinux.org/archlinux/packaging/packages/inetutils/-/issues/2#note_211062 for context.