[PR] fix cpu fetching code for leopard and tiger (#387)

* fix cpu fetching code for leopard and tiger

* some 10.5 systems have this sysctl, just check if it exists like this
This commit is contained in:
Un1q32 2025-02-15 09:03:48 -05:00 committed by GitHub
parent e691b2d9da
commit 5c24bd443a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3175,19 +3175,10 @@ END
;;
"Mac OS X"|"macOS")
if [[ $osx_version == 10.[4-5]* ]]; then
cpu="$(system_profiler SPHardwareDataType | grep CPU\ Type)"
cpu="${cpu/CPU\ Type\:/}"
speed="$(system_profiler SPHardwareDataType | grep CPU\ Speed)"
speed="${speed/CPU\ Speed\:/}"
speed="${speed/ MHz/}"
speed="${speed/ GHz/}"
cores="$(system_profiler SPHardwareDataType | grep Number\ Of\ CPUs)"
cores="${cores/Number\ Of\ CPUs\:/}"
else
cpu="$(sysctl -n machdep.cpu.brand_string)"
cpu="$(sysctl -n machdep.cpu.brand_string 2>/dev/null)"
if [ -z "$cpu" ]; then
cpu="$(system_profiler SPHardwareDataType | grep Processor\ Name)"
cpu="${cpu/Processor\ Name\:/}"
fi
# Get CPU cores.
@ -3374,7 +3365,6 @@ END
cpu="${cpu//[1-9][0-9]-Core}"
cpu="${cpu//[0-9]-Core}"
cpu="${cpu//, * Compute Cores}"
cpu="${cpu//Core / }"
cpu="${cpu//(\"AuthenticAMD\"*)}"
cpu="${cpu//with Radeon*Graphics}"
cpu="${cpu//, altivec supported}"