From 240a1d34bd5d98fb8a7d75cd1053d8abf1c73f64 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Wed, 30 Nov 2022 12:44:50 +0100 Subject: [PATCH] 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. --- modules.d/99base/dracut-lib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.47.3