From 0600bbf1137a9839dc1068b0b0e23a1a7d13b70c Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sat, 8 Feb 2020 04:45:22 +0100 Subject: [PATCH] Simplify grep-based conditionals The "-q" argument avoids the requirement for output redirections. --- plugins/cpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/cpu b/plugins/cpu index b34a363..2d0b519 100644 --- a/plugins/cpu +++ b/plugins/cpu @@ -1,6 +1,6 @@ config_cpu() { extinfo="" - if grep '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat >/dev/null 2>&1; then + if grep -q '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat; then extinfo="iowait irq softirq" fi # shellcheck disable=SC2126 @@ -68,7 +68,7 @@ config_cpu() { } fetch_cpu() { extinfo="" - if grep '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat >/dev/null 2>&1; then + if grep -q '^cpu \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\} \{1,\}[0-9]\{1,\}' /proc/stat; then extinfo="iowait irq softirq" fi CINFO=$(grep '^cpu ' /proc/stat | cut -c6-)