summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwileyhy <84648683+wileyhy@users.noreply.github.com>2023-04-28 19:57:20 -0700
committerJaroslav Kysela <perex@perex.cz>2023-05-03 16:36:04 +0200
commit37e396cab4edd01384916e8310fae01ab67b53c3 (patch)
tree50996cbd1bdaa9a9eb9cdd77642fb037dec1c2c2
parent4588b2f8aebb00f94ecd9b6029ddb0de82fd6d94 (diff)
downloadalsa-utils-37e396cab4edd01384916e8310fae01ab67b53c3.tar.gz
alsa-info.sh: uname - reduce execs by four, and eliminate a logic bug
Per `info uname`, `uname` always prints its data in the same order. Also, "note that A && B || C is not if-then-else. C may run when A is true." https://www.shellcheck.net/wiki/SC2015 set -x; read -r KERNEL_VERSION < <(uname -v); smp=x; \ [[ "$KERNEL_VERSION" = *SMP* ]] && \ { smp=y; readonly smp; false;} || smp=n; set - ... https://github.com/koalaman/shellcheck Fixes: https://github.com/alsa-project/alsa-utils/pull/207 From: wileyhy @ github Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rwxr-xr-xalsa-info/alsa-info.sh8
1 files changed, 3 insertions, 5 deletions
diff --git a/alsa-info/alsa-info.sh b/alsa-info/alsa-info.sh
index 4934d70..1979686 100755
--- a/alsa-info/alsa-info.sh
+++ b/alsa-info/alsa-info.sh
@@ -415,11 +415,9 @@ fi
# Fetch the info and store in temp files/variables
TSTAMP=$(LANG=C TZ=UTC date)
DISTRO=$(grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus\|ALT" /etc/{issue,*release,*version})
-KERNEL_VERSION=$(uname -r)
-KERNEL_PROCESSOR=$(uname -p)
-KERNEL_MACHINE=$(uname -m)
-KERNEL_OS=$(uname -o)
-[[ $(uname -v | grep SMP) ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No"
+read -r KERNEL_RELEASE KERNEL_MACHINE KERNEL_PROCESSOR KERNEL_OS < <(uname -rpmo)
+read -r KERNEL_VERSION < <(uname -v)
+if [[ "$KERNEL_VERSION" = *SMP* ]]; then KERNEL_SMP=Yes; else KERNEL_SMP=No; fi
ALSA_DRIVER_VERSION=$(cat /proc/asound/version | head -n1 | awk '{ print $7 }' | sed 's/\.$//')
get_alsa_library_version
ALSA_UTILS_VERSION=$(amixer -v | awk '{ print $3 }')