about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2009-01-29 17:18:59 +0000
committerClint Adams <clint@users.sourceforge.net>2009-01-29 17:18:59 +0000
commit9a2e1862e0b62edf8bcfc8f5cbfb16dd90c0e9ce (patch)
treed1f0fc2ce6e6e2ce9d98bd4c6b257342e006b8bc
parent9f7fc4497a65d71cadaf4105a313f65e8fa1f55b (diff)
downloadzsh-9a2e1862e0b62edf8bcfc8f5cbfb16dd90c0e9ce.tar.gz
zsh-9a2e1862e0b62edf8bcfc8f5cbfb16dd90c0e9ce.tar.xz
zsh-9a2e1862e0b62edf8bcfc8f5cbfb16dd90c0e9ce.zip
Jörg Sommer: 26453: complete modinfo -k.
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Linux/Command/_modutils12
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ca7c6057..e8c9fad7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
 	deprecated.
 	* Jörg Sommer: 26452: Completion/Linux/Command/_modutils: drop
 	completion of modinfo -f.
+	* Jörg Sommer: 26453: Completion/Linux/Command/_modutils: complete
+	modinfo -k.
 
 2009-01-29  Peter Stephenson  <pws@csr.com>
 
@@ -11043,5 +11045,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4535 $                         
+* $Revision: 1.4536 $                         
 *****************************************************
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils
index 3213524d7..879f64271 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_modutils
@@ -1,6 +1,7 @@
 #compdef lsmod modinfo modprobe rmmod insmod
 
 local curcontext="$curcontext" expl state line modules ign args ret=1
+local -r modules_dir=/lib/modules
 
 args=(
   '(-)'{-V,--version}'[print version]'
@@ -19,6 +20,8 @@ case "$service" in
       '(-)'{-p,--parameters}'[display the typed parameters that a module may support]' \
       '(-)'{-F,--field}"[display only selected module's information]:module_field:(
         alias author depends description filename license parm)" \
+      '(-)-k[use modules from a different kernel version]:kernel_version:(
+        $(echo $modules_dir/*(/\:t)))' \
       '1:module file:->all_modules' && ret=0
   ;;
 
@@ -77,7 +80,14 @@ case "$state" in
   ;&
 
   all_modules)
-    modules=( /lib/modules/$(uname -r)/(*~source)/**/*(.:t:r) )
+    local kver
+    integer kver_idx
+    if (( kver_idx=${words[(I)-k]} )); then
+      kver=${words[kver_idx+1]}
+    else
+      kver=$(uname -r)
+    fi
+    modules=( $modules_dir/$kver/(*~source)/**/*(.:t:r) )
 
     if [[ $state = loadable_modules ]]; then
         modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} )