[arch-projects] [mkinitcpio] [PATCH 2/4] functions: refactor all_modules

Dave Reisner d at falconindy.com
Fri Jun 3 14:13:07 EDT 2011


sanitize and print during module discovery. We also strip path names
during this process and null terminate path names for safety.

Signed-off-by: Dave Reisner <d at falconindy.com>
---
 functions |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/functions b/functions
index a89fd92..c93701d 100644
--- a/functions
+++ b/functions
@@ -52,11 +52,16 @@ auto_modules ()
 
 all_modules ()
 {
-    mods=$(find ${MODULEDIR} -name '*.ko' -or -name '*.ko.gz' 2>/dev/null | grep $@ | sort -u)
+    local -i count=0
+    while read -r -d '' mod; do
+        (( ++count ))
+        mod=${mod##*/}
+        mod="${mod%.ko.*}"
+        printf '%s\n' "${mod//-/_}"
+    done < <(find "$MODULEDIR" -name '*.ko' -o -name '*.ko.gz' -print0 2>/dev/null |
+        grep -Zz "$@" | sort -zu)
 
-    echo "${mods}"
-    [ -z "${mods}" ] && return 1
-    return 0
+    (( count ))
 }
 
 checked_modules ()
-- 
1.7.5.4



More information about the arch-projects mailing list