From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19225 invoked by alias); 10 Dec 2011 17:35:18 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16616 Received: (qmail 24626 invoked from network); 10 Dec 2011 17:35:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_MED,T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 128.2.11.95 is neither permitted nor denied by SPF record at _spf.google.com) Date: Sat, 10 Dec 2011 12:03:48 -0500 From: gi1242+zsh@gmail.com To: zsh-users@zsh.org Subject: modutils completion update Message-ID: <20111210170348.GB8394@andrew.cmu.edu> Mail-Followup-To: gi1242+zsh@gmail.com, zsh-users@zsh.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dc+cDN39EJAMEtIO" Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-PMX-Version: 5.5.9.388399, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.5.19.222118 X-SMTP-Spam-Clean: 34% ( RDNS_SUSP_FORGED_FROM 3.5, FORGED_FROM_GMAIL 0.1, MIME_TEXT_ONLY_MP_MIXED 0.05, SUPERLONG_LINE 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_10000_PLUS 0, DATE_TZ_NEG_0500 0, NO_REAL_NAME 0, NO_URI_FOUND 0, RDNS_BROADBAND 0, RDNS_GENERIC_POOLED 0, RDNS_POOLED 0, RDNS_SUSP 0, RDNS_SUSP_GENERIC 0, RDNS_SUSP_SPECIFIC 0, __CD 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __PHISH_SPEAR_STRUCTURE_1 0, __RDNS_BROADBAND_5 0, __RDNS_POOLED_11 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __USER_AGENT 0) X-SMTP-Spam-Score: 34% X-Scanned-By: MIMEDefang 2.60 on 128.2.11.95 --dc+cDN39EJAMEtIO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I fixed a caching problem for modutils. Also, since I'm defining the cache_invalid function, I thought it would be more efficient to define a _modutils function, and call that at the end of the script (to avoid redefining the cache function every time). I also changed sw from 2 to 4 (cosmetic), since the other files seemed to have 4. GI -- A gossip is someone with a great sense of rumor. --dc+cDN39EJAMEtIO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="modutils.patch" diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index e2671f2..48aeee9 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -2,143 +2,145 @@ _modules_caching_policy() { - # Rebuild every week, or if $modules_dir is newer than the cache - local -a oldp + # Rebuild if $modules_dir is newer than the cache, or every week. + local -a oldp - oldp=( "$1"(Nmw+1) ) - (( $#oldp )) || [[ $modules_dir -nt $1 ]] + oldp=( "$1"(Nmw+0) ) + (( $#oldp )) || [[ $modules_dir -nt $1 ]] } -local curcontext="$curcontext" expl state line modules ign args ret=1 -local -r modules_dir=/lib/modules - -local update_policy -zstyle -s ":completion:*:*:$service:*" cache-policy update_policy -if [[ -z "$update_policy" ]]; then - zstyle ":completion:*:*:$service:*" cache-policy _modules_caching_policy -fi - -args=( - '(-)'{-V,--version}'[print version]' - '(-)'{-h,--help}'[print help text]' -) - -case "$service" in - lsmod) _arguments -s "$args[@]" && return ;; - - modinfo) - _arguments -s -C "$args[@]" \ - '(-)'{-a,--author}"[display the module's author]" \ - '(-)'{-d,--description}"[display the module's description]" \ - '(-)'{-l,--license}"[display the module's license]" \ - '(-)'{-n,--filename}"[display the module's filename]" \ - '(-)'{-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 - ;; - - modprobe) - 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 -t --type -a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \ - "(* -l --list -r --remove $ign)"{-l,--list}'[list matching 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 - ;; - - 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' && ret=0 - ;; - - insmod) - _arguments \ - '1:module file:_files' \ - '*:module parameters:' && ret=0 - ;; -esac - -case "$state" in - loaded_modules|loadable_modules) - if [[ -r /proc/modules ]]; then - loaded_modules=(${${(f)"$(/dev/null)"}:#parm:*}##parm:[[:space:]]##} ) - if [[ $#params -eq 0 ]]; then - _message -e parameter "This modules doesn't have parameters" - else - typeset -A val_args - - _values -S = -C -w 'module parameter' \ - ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} \ - ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0 - fi - fi - ;; -esac + args=( + '(-)'{-V,--version}'[print version]' + '(-)'{-h,--help}'[print help text]' + ) + + case "$service" in + lsmod) _arguments -s "$args[@]" && return ;; + + modinfo) + _arguments -s -C "$args[@]" \ + '(-)'{-a,--author}"[display the module's author]" \ + '(-)'{-d,--description}"[display the module's description]" \ + '(-)'{-l,--license}"[display the module's license]" \ + '(-)'{-n,--filename}"[display the module's filename]" \ + '(-)'{-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 + ;; + + modprobe) + 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 -t --type -a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \ + "(* -l --list -r --remove $ign)"{-l,--list}'[list matching 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 + ;; + + 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' && ret=0 + ;; + + insmod) + _arguments \ + '1:module file:_files' \ + '*:module parameters:' && ret=0 + ;; + esac + + case "$state" in + loaded_modules|loadable_modules) + if [[ -r /proc/modules ]]; then + loaded_modules=(${${(f)"$(/dev/null)"}:#parm:*}##parm:[[:space:]]##} ) + if [[ $#params -eq 0 ]]; then + _message -e parameter "This modules doesn't have parameters" + else + typeset -A val_args + + _values -S = -C -w 'module parameter' \ + ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0 + fi + fi + ;; + esac + + return ret +} -return ret +_modutils "$@" --dc+cDN39EJAMEtIO--