From: Benjamin Drung Date: Sat, 24 Jan 2026 15:36:23 +0000 (+0100) Subject: perf(dracut): replace grep by bash pattern matching X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddd6a7d3df1c4c5b69d177649279fb82532c2e8a;p=thirdparty%2Fdracut-ng.git perf(dracut): replace grep by bash pattern matching Replace `echo | grep` by a bash pattern matching to avoid spawning external processes. The bash pattern matching should be faster. --- diff --git a/dracut.sh b/dracut.sh index 8c5fa87df..b8f6c8a75 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2078,7 +2078,7 @@ fi CPIO=cpio if command -v 3cpio > /dev/null; then if threecpio_help_output=$(3cpio --help); then - if echo "$threecpio_help_output" | grep -q -- --create; then + if [[ $threecpio_help_output == *--create* ]]; then CPIO=3cpio else dinfo "3cpio does not support --create. Falling back to cpio." diff --git a/lsinitrd.sh b/lsinitrd.sh index 4a26bd4af..63cf7b589 100755 --- a/lsinitrd.sh +++ b/lsinitrd.sh @@ -99,7 +99,7 @@ done CPIO=cpio if command -v 3cpio > /dev/null; then if threecpio_help_output=$(3cpio --help); then - if echo "$threecpio_help_output" | grep -q -- --make-directories; then + if [[ $threecpio_help_output == *--make-directories* ]]; then CPIO=3cpio fi elif command -v cpio > /dev/null; then