From c90e63b2998312e4c9aa029599df2c0b184faaa6 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:39:35 +0800 Subject: [PATCH] os: add `uname` method This will allow us to replace code like os = if OS.mac? "Darwin" else "Linux" end with a call to `OS.uname`. Doing rg '= (if )?OS\.(mac|linux)\?' returns about 70 matches, so there are probably at least a handful of formulae that could be simplified by this. --- Library/Homebrew/os.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index ca2924c97f..17e9076dca 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -35,6 +35,14 @@ module OS @kernel_version ||= Version.new(Utils.safe_popen_read("uname", "-r").chomp) end + # Get the kernel name. + # + # @api public + sig { returns(String) } + def self.uname + @uname ||= Utils.safe_popen_read("uname").chomp + end + ::OS_VERSION = ENV["HOMEBREW_OS_VERSION"] CI_GLIBC_VERSION = "2.23"