unixorn/tumult.plugin.zsh

View on GitHub
bin/macos-major-version

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash
#
# Copyright 2020, Joe Block <jpb@unixorn.net>
#
# macOS has a habit of changing the way it does some of its non-posixy things
# every major rev or so. Add a helper to standardize detecting the rev

set -o pipefail
if [[ "$(uname -s)" != 'Darwin' ]]; then
  echo 'Sorry, this script only works on macOS'
  exit 1
fi

sw_vers -productVersion | awk -F '.' '{print $1 "." $2}'