refactor: avoid subshell

This commit is contained in:
Daniel Langbein 2023-03-16 17:20:48 +01:00
parent 03e1135e4c
commit 2e3db5e3dc

View File

@ -61,13 +61,13 @@ function get_cpu_vendor() {
if [[ -z "${CPU_VENDOR}" ]] || [[ "${CPU_VENDOR}" == 'autodetect' ]]; then if [[ -z "${CPU_VENDOR}" ]] || [[ "${CPU_VENDOR}" == 'autodetect' ]]; then
# If run virtual environment (e.g. VirtualBox) then no CPU microcode is required # If run virtual environment (e.g. VirtualBox) then no CPU microcode is required
if cat /proc/cpuinfo | grep '^flags.*hypervisor' >/dev/null; then if grep '^flags.*hypervisor' /proc/cpuinfo >/dev/null; then
echo 'Detected virtual environment.' echo 'Detected virtual environment.'
CPU_VENDOR='none' CPU_VENDOR='none'
else else
local vendor_id local vendor_id
vendor_id=$(cat /proc/cpuinfo | grep vendor_id | head -1 | sed 's|vendor_id\s*:\s*||') vendor_id=$(grep vendor_id /proc/cpuinfo | head -1 | sed 's|vendor_id\s*:\s*||')
if [ "${vendor_id}" = 'AuthenticAMD' ]; then if [ "${vendor_id}" = 'AuthenticAMD' ]; then
CPU_VENDOR='amd' CPU_VENDOR='amd'