From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2412 invoked from network); 16 Apr 2003 13:26:20 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Apr 2003 13:26:20 -0000 Received: (qmail 5434 invoked by alias); 16 Apr 2003 13:26:14 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18446 Received: (qmail 5427 invoked from network); 16 Apr 2003 13:26:14 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 16 Apr 2003 13:26:14 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.125.75.4] by sunsite.dk (MessageWall 1.0.8) with SMTP; 16 Apr 2003 13:26:13 -0000 Received: (qmail 12573 invoked from network); 16 Apr 2003 13:26:08 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-3.tower-1.messagelabs.com with SMTP; 16 Apr 2003 13:26:08 -0000 Received: from gmcs3.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id OAA14240 for ; Wed, 16 Apr 2003 14:26:08 +0100 X-Authentication-Warning: iris.logica.co.uk: Host [158.234.142.61] claimed to be gmcs3.logica.co.uk Received: from gmcs3.logica.co.uk (localhost [127.0.0.1]) by gmcs3.logica.co.uk (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h3GDPtb04946 for ; Wed, 16 Apr 2003 15:25:55 +0200 X-VirusChecked: Checked From: Oliver Kiddle To: Zsh workers Subject: PATCH: updated _modutils Date: Wed, 16 Apr 2003 15:25:55 +0200 Message-ID: <4944.1050499555@gmcs3.logica.co.uk> Now handles modinfo and lsmod, makes use of the grouping of options with the same description, better exclusion lists and more resilient to modprobe not being in your path. Oliver --- Completion/Linux/Command/_modutils Tue Apr 1 14:09:37 2003 +++ Completion/Linux/Command/_modutils Wed Apr 16 15:21:09 2003 @@ -1,87 +1,83 @@ -#compdef modprobe rmmod +#compdef lsmod modinfo modprobe rmmod -local curcontext="$curcontext" state line expl loaded +local curcontext="$curcontext" expl state line modules ign args -_modutils_loaded_modules() { - -if [[ -r /proc/modules ]]; then - loaded=(${${(f)"$(all_modules' && return ;; modprobe) - - _modprobe_arguments=( - '(--all)-a[all]' \ - '(-a)--all' \ - '(--showconfig)-c[showconfig]' \ - '(-c)--showconfig' \ - '(--debug)-d[debug]' \ - '(-d)--debug' \ - '(--autoclean)-k[set autoclean]' \ - '(-k)--autoclean' \ - '(--show)-n[do not act]' \ - '(-n)--show' \ - '(--quiet)-q[do not complain about insmod failures]' \ - '(-q)--quiet' \ - '(--syslog)-s[report via syslog instead of stderr]' \ - '(-s)--syslog' \ - '(--type)-t[module type]:moduletype:' \ - '(-t)--type:moduletype:' \ - '(--verbose)-v[print all commands as executed]' \ - '(-v)--verbose' \ - '(--version)-V[show release version]' \ - '(-V)--version' \ - '(--config)-C[config file]:config file:_files' \ - '(-C)--config:config file:_files' - ) - - _arguments -C '(--remove)-r[remove]:*:loaded module:->modprobe_remove' \ - '(-r)--remove:*:loaded module:->modprobe_remove' \ - '(--list)-l[list matching modules]:*:module file:->modprobe_list' \ - '(-l)--list:*:module file:->modprobe_list' \ - "$_modprobe_arguments[@]" && return 0 - + ign='-h --help -V --version -c --showconfig' + _arguments -s -C "$args[@]" \ + "(-a --all $ign)"{-a,--all}'[load all matching modules]' \ + '(-)'{-c,--showconfig}'[show current configuration]' \ + "(-d --debug $ign)"{-d,--debug}'[print debug info]' \ + "(-k --autoclean $ign)"{-k,--autoclean}'[set autoclean]' \ + "(-n --show $ign)"{-n,--show}"[don't actually perform action]" \ + "(-q --quiet $ign)"{-q,--quiet}"[don't complain about insmod failures]" \ + "(-s --syslog $ign)"{-s,--syslog}'[report via syslog instead of stderr]' \ + "(* -t --type $ign)"{-t,--type}'[module type]:module type' \ + "(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \ + '(-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 -l --list -t --type $ign)*:modules:->params" && return + + [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules ;; + rmmod) + _arguments -s -C "$args[@]" \ + '(-a --all)'{-a,--all}'[remove all unused autocleanable modules]' \ + '(-e --persist)'{-e,--persist}'[save persistent data]' \ + '(-r --stacks)'{-r,--stacks}'[remove a module stack]' \ + '(-s --syslog)'{-s,--syslog}'[output to syslog]' \ + '(-v --verbose)'{-v,--verbose}'[be verbose]' \ + '*:loaded module:->loaded_modules' && return + ;; esac case "$state" in - modprobe_remove) - _call_function ret _modutils_$state && return ret - _arguments "$_modprobe_arguments[@]" \ - '*:loaded module:_modutils_loaded_modules' + loaded_modules) + if [[ -r /proc/modules ]]; then + modules=(${${(f)"$(/dev/null)"}:#path*}#*[=]} ) + _wanted modules expl module compadd ${^modules}/**/*.o(:t:r) && return + ;; + params) + if compset -P '*='; then + _message -e value 'parameter value' + else + _message -e parameter 'module parameter' + fi + ;; esac + +return 1