cache_uname: improve reading from 'SystemVersion.plist' on macOS and iOS

and thus fix neofetch for iOS 11.3+
This commit is contained in:
jkhsjdhjs 2019-03-13 19:02:18 +01:00
parent cc78503b58
commit d0cd21c01e
No known key found for this signature in database
GPG key ID: BAC6ADBAB7D576CC

View file

@ -4199,11 +4199,16 @@ cache_uname() {
kernel_machine="${uname[2]}"
if [[ "$kernel_name" == "Darwin" ]]; then
IFS=$'\n' read -d "" -ra sw_vers < <(awk -F'<|>' '/string/ {print $3}' \
IFS=$'\n' read -d "" -ra sw_vers < <(awk -F'<|>' '/key|string/ {print $3}' \
"/System/Library/CoreServices/SystemVersion.plist")
darwin_name="${sw_vers[2]}"
osx_version="${sw_vers[3]}"
osx_build="${sw_vers[0]}"
for i in "${!sw_vers[@]}"; do
local value="${sw_vers[(( $i + 1 ))]}"
case "${sw_vers[$i]}" in
"ProductName") darwin_name="$value" ;;
"ProductVersion") osx_version="$value" ;;
"ProductBuildVersion") osx_build="$value" ;;
esac
done
fi
}