aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/ruby/library/etc/getlogin_spec.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/spec/ruby/library/etc/getlogin_spec.rb b/spec/ruby/library/etc/getlogin_spec.rb
index 43e654bda6..f5da1039f5 100644
--- a/spec/ruby/library/etc/getlogin_spec.rb
+++ b/spec/ruby/library/etc/getlogin_spec.rb
@@ -18,7 +18,12 @@ describe "Etc.getlogin" do
else
# Etc.getlogin returns the same result of logname(2)
# if it returns non NULL
- Etc.getlogin.should == `id -un`.chomp
+ if system("which logname", out: File::NULL, err: File::NULL)
+ Etc.getlogin.should == `logname`.chomp
+ else
+ # fallback to `id` command since `logname` is not available
+ Etc.getlogin.should == `id -un`.chomp
+ end
end
else
# Etc.getlogin may return nil if the login name is not set