From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 11826d40 for ; Wed, 15 May 2019 22:05:16 +0000 (UTC) Received: (qmail 3833 invoked by alias); 15 May 2019 22:05:05 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44308 Received: (qmail 29260 invoked by uid 1010); 15 May 2019 22:05:05 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25447. spamassassin: 3.4.2. Clear:RC:0(205.235.26.22):SA:0(-1.9/5.0):. Processed in 0.828088 secs); 15 May 2019 22:05:05 -0000 X-Envelope-From: SRS0=2XHT=TP=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at bounces.park01.gkg.net designates 205.235.26.22 as permitted sender) X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1557957866; bh=fa0rqWKas4W0MGy0TiTs+DbIfgLR82BNE/89CjsPWCA=; h=From:To:Subject:Date:From:Subject; b=KUFePhGtv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Y5SBGRNKAKXX8kv Ef7TO_Qr2ONmsWFRDARF.HrebLGjEByJIu9u7_prFifw.n9RG_DP2u7AczYrZ_uhngRVG71dVakG xA5c.6ek6cr3igKzeHS7Vy_bgIT79xEYpogXxw113hHw7LzC28YsIt3cPLEZaokj7bQ6ExMzz3W5 ICNPNRzX2dFbDsYZSi7xgEokRfH9bHYMEhK3EtckB4optOIKywxUgpntDz1S8PrNof07yVnwU6jp hlSui7yU_QHjMKcfOxEurT8HWXq2YKrpcfHmK.uqEw.sIWBqv6DkUq3qOjQ8PkkrbJIdIyKqWfzM KcLWshtvVfXhuI01R0ElnCjm9mhjk4I0qbWPqmwiibeSFrT3LCYR8ewL8dErzKY.JH7czmbIg44t TBS_KkJaWHVS67Wbtrc3YJORccV_9MMrCMQzTSRAvsT13W10qv6WjYu0A1k6xnibMcKGUFEdEV7c ODS6fkPJuq9cUBKgh.Sd_xYKm From: Oliver Kiddle To: Zsh workers Subject: PATCH: update Linux modutils completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <76532.1557957863.1@hydra> Date: Thu, 16 May 2019 00:04:23 +0200 Message-ID: <76533-1557957863.948068@y8kK.jpg4.LGma> Options to the various Linux modutils commands have changed quite a bit so this brings the completion up-to-date. This touched on most lines in the file so I've reindented the file to follow usual conventions. Git has done a good job of keeping related blocks together so the diff is easy to follow despite. Oliver diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index 9a37fcae1..ff6844f41 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -10,138 +10,146 @@ _modules_caching_policy() } _modutils() { - local curcontext="$curcontext" expl state line modules ign args ret=1 - local -r modules_dir=/lib/modules + local curcontext="$curcontext" expl state line modules modaliases ign args ret=1 + local -A opt_args + 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 + 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]' - ) + args=( + '(-)'{-V,--version}'[display version information]' + '(-)'{-h,--help}'[display usage information]' + ) - case "$service" in - lsmod) _arguments -s "$args[@]" && return ;; + 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 - ;; + modinfo) + _arguments -s -C "$args[@]" \ + '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ + {-b+,--basedir=}'[use specified directory as filesystem root]:path:_directories' \ + '1:module file:->all-modules' \ + + '(field)' \ + {-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 intree license name parm sig_hashalgo sig_key signat signer srcversion vermagic)" \ + {-0,--null}'[use a null instead of newline in output]' && 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 + modprobe) + ign='-h --help -V --version -c --showconfig --show-config' + _arguments -s -C "$args[@]" \ + "(-a --all $ign)"{-a,--all}'[load all matching modules]' \ + "(-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]' \ + "(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \ + '(-C --config)'{-C+,--config=}'[specify config file]:config file:_files' \ + "(-r --remove -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \ + '--remove-dependencies[also remove modules depending on it]' \ + '(* -R --resolve-alias)'{-R,--resolve-alias}'[only lookup and print alias and exit]' \ + '--first-time[fail if module already inserted or removed]' \ + "(-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]'} \ + '(-b --use-blacklist)'{-b,--use-blacklist}'[apply blacklist to resolved alias]' \ + '(-f --force --force-modversions --force-vermagic)'{-f,--force}'[force module insertion or removal]' \ + "(-f --force)--force-modversion[ignore module's version]" \ + "(-f --force)--force-vermagic[ignore module's version magic]" \ + '(-D --show-depends)'{-D,--show-depends}'[only print module dependencies and exit]' \ + '(-)'{-c,--showconfig,--show-config}'[show current configuration]' \ + --{show,dump}'-modversions[dump module symbol version and exit]' \ + {-d+,--dirname=}'[use specified directory as filesystem root]:path:_directories' \ + {-S+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ + '--show-exports[only print module exported symbol versions and exit]' \ + '(-n --dry-run --show)'{-n,--dry-run,--show}"[don't execute operations, just print]" \ + "(-c $ign)1:modules:->loadable-modules" \ + "(-c $ign)*:params:->params" && ret=0 - [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules - ;; + [[ -n $state && -n ${opt_args[(i)(-r|--remove)]} ]] && 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 - ;; + rmmod) + _arguments -s -C "$args[@]" \ + '(-f --force)'{-f,--force}'[allow modules that are in use to be removed]' \ + '(-s --syslog)'{-s,--syslog}'[send errors 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 + insmod) + _arguments "$args[@]" \ + '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 + params) + if compset -P 1 '*='; then + _message -e value 'parameter value' + else + local params + params=( ${${(M)${(f)"$(_call_program module-parameters /sbin/modinfo "$words[2]" 2>/dev/null)"}:#parm:*}##parm:[[:space:]]##} ) + compset -S '=*' + if (( $#params )); then + _values -S = -w 'module parameter' \ + ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0 + else + _message -e parameter "module doesn't take parameters" + fi + fi + ;; + esac - _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 "$@"