summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2025-03-08 18:19:14 +0900
committernagachika <nagachika@ruby-lang.org>2025-03-08 18:19:14 +0900
commitfff5baf200572762a60c624bc7bea866992c2f30 (patch)
tree9e0dfaa60963dbec48f219c792742a8ffc06fbae
parent54dd27d89d2e6814114f1aff18836a987d5a4ab1 (diff)
merge revision(s) 46b544c54955348ef1ea9692b837b061f59f91cd, d3abee739f4feb91bb9aaae33877d70c8c576db0: [Backport #21095]
Prefer `uname -n` over `hostname`. (#12647) Add fallback for `hostname` if `uname` isn't available. (#12655)
-rw-r--r--spec/ruby/library/socket/socket/gethostname_spec.rb10
-rw-r--r--version.h2
2 files changed, 10 insertions, 2 deletions
diff --git a/spec/ruby/library/socket/socket/gethostname_spec.rb b/spec/ruby/library/socket/socket/gethostname_spec.rb
index 4b79747b27..89e1ed496f 100644
--- a/spec/ruby/library/socket/socket/gethostname_spec.rb
+++ b/spec/ruby/library/socket/socket/gethostname_spec.rb
@@ -2,7 +2,15 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
describe "Socket.gethostname" do
+ def system_hostname
+ # Most platforms implement this POSIX standard:
+ `uname -n`.strip
+ rescue
+ # Only really required for Windows without MSYS/MinGW/Cygwin etc:
+ `hostname`.strip
+ end
+
it "returns the host name" do
- Socket.gethostname.should == `hostname`.strip
+ Socket.gethostname.should == system_hostname
end
end
diff --git a/version.h b/version.h
index 6065964a68..2c823ebf70 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 126
+#define RUBY_PATCHLEVEL 127
#include "ruby/version.h"
#include "ruby/internal/abi.h"