Skip to content

Instantly share code, notes, and snippets.

@carlashley
Created July 26, 2017 02:19
Show Gist options
  • Save carlashley/1b76d6988a0283b9e0ff36a7f1ecb355 to your computer and use it in GitHub Desktop.
Save carlashley/1b76d6988a0283b9e0ff36a7f1ecb355 to your computer and use it in GitHub Desktop.
Gets macOS X Installer app version.
#!/bin/sh
# Shamelessly stolen from https://loefflmann.blogspot.com.au/2015/03/finding-os-x-version-and-build-in-install-os-x-app.html
# Provide the path to the installer file from the command line.
if [[ ! -z $1 ]]; then
os_installer_path="$1"
echo "Attaching ${1}"
hdiutil attach "${os_installer_path}/Contents/SharedSupport/InstallESD.dmg" -quiet -noverify -nobrowse -mountpoint /Volumes/InstallESD.$$
hdiutil attach "/Volumes/InstallESD.$$/BaseSystem.dmg" -quiet -noverify -nobrowse -mountpoint /Volumes/BaseSystem.$$
os_ver=$(defaults read "/Volumes/BaseSystem.$$/System/Library/CoreServices/SystemVersion.plist" ProductVersion)
build=$(defaults read "/Volumes/BaseSystem.$$/System/Library/CoreServices/SystemVersion.plist" ProductBuildVersion)
echo "OS Version: ${os_ver} (${build})"
echo "Detaching ${1}"
hdiutil detach "/Volumes/BaseSystem.$$" -quiet
hdiutil detach "/Volumes/InstallESD.$$" -quiet
else
echo "Please specify path to macOS Install application."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment