Posted on 07-30-2024 02:24 AM
Happy Tuesday, Jamf Nation!
Looks like the behavior of `brew -v` changed with Homebrew version 4.3.11.
On the off-chance the following mostly untested EA proves helpful to other Jamf Pro admins:
#!/bin/zsh --no-rcs
# shellcheck shell=bash
####################################################################
# ABOUT #
# #
# A script to collect the version of Homebrew currently installed. #
# If Homebrew is not installed, "Not Installed" will returned. #
# #
####################################################################
# #
# HISTORY #
# #
# Version 0.0.1, 30-Jul-2024, Dan K. Snelson (@dan-snelson) #
# - Original version (inspired by M. Lamont) #
# #
####################################################################
# Set default for RESULT
RESULT="Not Installed"
# Last Logged-in User
lastUser=$( defaults read /Library/Preferences/com.apple.loginwindow.plist lastUserName )
# Determine Homebrew version, based on Mac's Architecture
arch=$(/usr/bin/arch)
if [[ "$arch" == "arm64" ]]; then
if [[ -e /opt/homebrew/bin/brew ]]; then
RESULT=$( su - "${lastUser}" -c "brew --version" | awk '{ print $2 }' )
fi
elif [[ "$arch" == "i386" ]]; then
if [[ -e /usr/local/bin/brew ]]; then
RESULT=$( su - "${lastUser}" -c "brew --version" | awk '{ print $2 }' )
fi
else
RESULT="Unknown Architecture"
fi
# Output RESULT
/bin/echo "<result>$RESULT</result>"
Posted on 07-30-2024 02:57 AM