]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
perf(dracut): replace grep by bash pattern matching
authorBenjamin Drung <benjamin.drung@canonical.com>
Sat, 24 Jan 2026 15:36:23 +0000 (16:36 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sun, 25 Jan 2026 13:54:42 +0000 (08:54 -0500)
Replace `echo | grep` by a bash pattern matching to avoid spawning
external processes. The bash pattern matching should be faster.

dracut.sh
lsinitrd.sh

index 8c5fa87dffcaf2a98a9f528b5327289152527802..b8f6c8a7509d16d45ea7a805843244da806615c4 100755 (executable)
--- 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."
index 4a26bd4af0e6dca0e679f50d72c64945555e9383..63cf7b58987743f83352137874aaab9915a501a3 100755 (executable)
@@ -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