diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-27 19:57:25 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-09-27 19:57:25 +0000 |
commit | 4a34c9628942a3631500e51b57ce4ccb4ac77fb4 (patch) | |
tree | b1c0d6eba97bf68f361093f91e27cb4eddade013 /Completion/Linux | |
parent | 4ba03217caf578fab92202cd853d8de35aa047ed (diff) | |
download | zsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.tar.gz zsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.tar.xz zsh-4a34c9628942a3631500e51b57ce4ccb4ac77fb4.zip |
25755/25756: Jörg Sommer: improved handling of module arguments
25759: fix dynamic named directory crash, static named directory consistency
Diffstat (limited to 'Completion/Linux')
-rw-r--r-- | Completion/Linux/Command/_modutils | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index 732290363..e03b47184 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -36,7 +36,7 @@ case "$service" in '(-C --config)'{-C,--config}'[specify config file]:config file:_files' \ "(-r --remove -l --list -t --type -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \ "(* -l --list -r --remove $ign)"{-l,--list}'[list matching modules]' \ - "(-c $ign)1:modules:->all_modules" \ + "(-c $ign)1:modules:->loadable_modules" \ "(-c -l --list -t --type $ign)*:params:->params" && ret=0 [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules @@ -60,23 +60,31 @@ case "$service" in esac case "$state" in - loaded_modules) + loaded_modules|loadable_modules) if [[ -r /proc/modules ]]; then - modules=(${${(f)"$(</proc/modules)"}%% *}) + loaded_modules=(${${(f)"$(</proc/modules)"}%% *}) elif [[ -x /sbin/lsmod ]]; then - modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) + loaded_modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) else return 1 fi - - _wanted modules expl 'loaded module' compadd -a modules && return - ;; + + if [[ $state = loaded_modules ]]; then + _wanted modules expl 'loaded module' compadd -a loaded_modules && return + return ret + fi + ;& all_modules) modules=( ${${${${(f)"$(_call_program modules ${(M)words[1]##*/}modprobe -l 2>/dev/null)"}:#}##*/}%%.*} ) + + if [[ $state = loadable_modules ]]; then + modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} ) + fi + _tags files modules while _tags; do - _requested files expl "module file" _files && ret=0 + _requested files expl "module file" _files -g '*.ko' && ret=0 _requested modules expl module compadd -a modules && ret=0 done ;; |