3

In a shell script, how can I tell whether or not the script is running on a (public) beta version of macOS?

Preferrably, I would like to check this without matching a specific version of macOS, since even though macOS 12 Monterey, is beta right now, it won't be in the future.

10
  • To clarify: you're looking for some sort of flag/marker that identifies any given OS version as a beta, rather than a public release? So your script would identify betas of Catalina and Mojave, if someone is still running those, as well as betas of MacOS 15 "Vasquez Rocks" from the future? Can I ask what the script does?
    – benwiggy
    Sep 12 at 12:03
  • @benwiggy yes. The scenario is that I'm running a setup script that runs Homebrew. I run the same script on several computers. The ‘brew doctor‘ command reports warnings when running on beta and I want to ignore warnings only in that instance. Sep 12 at 12:07
  • 1
    A quick read of https://raw.githubusercontent.com/Homebrew/install/master/install.sh it sets MACOS_NEWEST_UNSUPPORTED="12.0" and ascertains the version by /usr/bin/sw_vers -productVersion which I'll assume on macOS Monterey it's currently returning 12.0. So maybe using a local copy of install.sh and editing it, changing 12.0 to 13.0, then use the local copy to install from would work. Don't know for sure, just spit balling, I have yet to play with macOS Monterey to test this. Sep 12 at 15:23
  • Wouldn't it be better to just not install Homebrew where it isn't supported? Sep 12 at 17:33
  • 1
    While a given version of MacOS is not a reliable indicator of the installation being a beta or a release, the BuildVersion may work better. Though I don't think there is anything inherent of all beta versions that is detectable, I think your best bet would be using the BuildVersion and a lookup table.
    – Scot
    Sep 13 at 0:53

You must log in to answer this question.

Browse other questions tagged .