From: Antonio Alvarez Feijoo Date: Wed, 30 Nov 2022 11:44:50 +0000 (+0100) Subject: fix(base): remove grep dependency X-Git-Tag: 058~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=240a1d34bd5d98fb8a7d75cd1053d8abf1c73f64;p=thirdparty%2Fdracut.git fix(base): remove grep dependency The base module requires grep with the `rd.memdebug=1` command line parameter. As this code is broken if grep is not added by other means and grep is only required for this, rewriting this code to avoid the dependency. --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 6ba836ec3..83ca9fab9 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -1104,7 +1104,13 @@ make_trace_mem() { show_memstats() { case $1 in shortmem) - grep -e "^MemFree" -e "^Cached" -e "^Slab" /proc/meminfo + while read -r line || [ -n "$line" ]; do + str_starts "$line" "MemFree" \ + || str_starts "$line" "Cached" \ + || str_starts "$line" "Slab" \ + || continue + echo "$line" + done < /proc/meminfo ;; mem) cat /proc/meminfo