From c89d0a0b73dfc82d918c326d89b141f8a2fc4de4 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 10 Sep 2020 20:33:18 +0100 Subject: [PATCH] fix(internal): improve macOS version detection Turns out that `sw_vers -productVersion` doesn't always return a version string with a `MAJOR.MINOR.PATCH` format, but can also just return two digits, like `11.0` on the current beta of macOS Big Sur. Fixes: #13 --- build-emacs-for-macos | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index a7e69f1..978e1e6 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -45,7 +45,7 @@ end class OSVersion def initialize @version = `sw_vers -productVersion`.match( - /(?\d+)\.(?\d+)\.(?\d+)/ + /(?\d+)(?:\.(?\d+)(:?\.(?\d+))?)?/ ) end @@ -54,15 +54,15 @@ class OSVersion end def major - @major ||= @version[:major].to_i + @major ||= @version[:major]&.to_i end def minor - @minor ||= @version[:minor].to_i + @minor ||= @version[:minor]&.to_i end def patch - @patch ||= @version[:patch].to_i + @patch ||= @version[:patch]&.to_i end end