I've been googling about the installer command and stumbled upon this post https://hvops.com/articles/ansible-mac-osx/. Turns out that pkgutil --pkg-info=com.apple.pkg.CLTools_Executables (for macOS X it's com.apple.pkg.DeveloperToolsCLI) exposes metadata that can be used to check whether Xcode CLI tools are present.
I've been googling about the
installer
command and stumbled upon this post https://hvops.com/articles/ansible-mac-osx/. Turns out thatpkgutil --pkg-info=com.apple.pkg.CLTools_Executables
(for macOS X it'scom.apple.pkg.DeveloperToolsCLI
) exposes metadata that can be used to check whether Xcode CLI tools are present.It seems like using it could be a more elegant/robust solution for making this check, compared to using
stat
. Have you considered using it?