Skip to content

Commit 240a1d3

Browse files
aafeijoo-susejohannbg
authored andcommitted
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.
1 parent 4a9b165 commit 240a1d3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules.d/99base/dracut-lib.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,13 @@ make_trace_mem() {
11041104
show_memstats() {
11051105
case $1 in
11061106
shortmem)
1107-
grep -e "^MemFree" -e "^Cached" -e "^Slab" /proc/meminfo
1107+
while read -r line || [ -n "$line" ]; do
1108+
str_starts "$line" "MemFree" \
1109+
|| str_starts "$line" "Cached" \
1110+
|| str_starts "$line" "Slab" \
1111+
|| continue
1112+
echo "$line"
1113+
done < /proc/meminfo
11081114
;;
11091115
mem)
11101116
cat /proc/meminfo

0 commit comments

Comments
 (0)