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.
This commit is contained in:
Carlo Cabrera 2021-09-09 22:39:35 +08:00
parent f50b87031e
commit c90e63b299
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -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"