I'm trying to calculate free space on Catalina. For prior versions of macOS, this piece from a script from Joshua Roskos' macOS Upgrade script works:
diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
freeSpace=$(
/usr/libexec/PlistBuddy -c "Print :FreeSpace" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :AvailableSpace" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
)
But on Catalina, the result is "0" every time. The FreeSpace key that is generated by:
/usr/sbin/diskutil info -plist /
is always "0" on Catalina. What needs to be changed to get the correct value for FreeSpace?
