summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-03 16:41:35 +0200
committerDave Reisner <d@falconindy.com>2011-06-07 20:38:37 +0200
commit4a69075b0a11a4ca982d4daa8b30dd6117e845d4 (patch)
tree891757455ffba86d50f9cc34b47fbccf440e4fb7 /functions
parent51d63c7556b5de04420dad4951c97199607f9b27 (diff)
downloadmkinitcpio-4a69075b0a11a4ca982d4daa8b30dd6117e845d4.tar.gz
mkinitcpio-4a69075b0a11a4ca982d4daa8b30dd6117e845d4.tar.xz
functions: refactor all_modules
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@falconindy.com>
Diffstat (limited to 'functions')
-rw-r--r--functions12
1 files changed, 8 insertions, 4 deletions
diff --git a/functions b/functions
index f179135..142b974 100644
--- a/functions
+++ b/functions
@@ -52,11 +52,15 @@ 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*' -print0 2>/dev/null | grep -Zz "$@")
- echo "${mods}"
- [ -z "${mods}" ] && return 1
- return 0
+ (( count ))
}
checked_modules ()