From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9829 invoked by alias); 17 Sep 2017 13:17:14 -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: X-Seq: 41720 Received: (qmail 22873 invoked by uid 1010); 17 Sep 2017 13:17:14 -0000 X-Qmail-Scanner-Diagnostics: from sonic309-24.consmr.mail.ir2.yahoo.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(77.238.179.82):SA:0(-4.7/5.0):. Processed in 4.15222 secs); 17 Sep 2017 13:17:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1505654223; bh=h8TzNj/Xaexzxky6nucfLrujQBFBt0x4zaa1Al4ZyC8=; h=From:To:Subject:Date:From:Subject; b=Fk3JP3RfDTv75TZEAQgDFVK5ef2N9yPaBE+LaeiaNkH4w0siDVOf93V+kLCTvT+9bvUt2jpbafFTZav5vwa1FypkklQfoENLTl6XsE3AKAAusOsfRATIzcW8VhvKrMFzlwrtUHm4wKcq9qvRWNcg+CyFTbjaH4Zo1qdYbaWQqNbqVyBWXn6uyesxxfPmUoCyHWBPjEkUnOtuxM3ofik91diQDBXSd9zdM2/X3zAH3FdyQrdX4kspg86tYvoVJ/ugZO8vSKcgOgcKh7CDU09KUCaMvUWO427YEvgbvU3HYcsjzq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_mh71zhYu_PRFdqWPcqgmtRt.A2yffztODw7xXhCoYgI Xi0RMPcWAxjJ46PNn3wYbeflTKeq3pxuGj56SmiRm9A8cMg-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: update util-linux completions MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30684.1505644895.1@thecus.kiddle.eu> Date: Sun, 17 Sep 2017 12:41:35 +0200 Message-ID: <30685.1505644895@thecus.kiddle.eu> This updates completions for some of the util-linux tools to 2.30.1. losetup seems to have been changed around a lot yet again. Completion for wipefs is new. For some things that come with util-linux, there are other implementations around, last for instance. It would be good to handle such cases better. Oliver diff --git a/Completion/Linux/Command/_chrt b/Completion/Linux/Command/_chrt index f82ec8b81..6789b66cf 100644 --- a/Completion/Linux/Command/_chrt +++ b/Completion/Linux/Command/_chrt @@ -1,61 +1,68 @@ #compdef chrt -local context state line +local curcontext="$curcontext" cmd="$words[1]" ret=1 +local -a state line expl typeset -A opt_args -_arguments \ +_arguments -C -s -S -A "-*" \ + '(H -a --all-tasks)'{-a,--all-tasks}'[operate on all tasks (threads) for a given pid]' \ + '(H)'{-v,--verbose}'[display status information]' \ + '(H)'{-p,--pid}'[interpret args as process ID]' \ + '(H -R --reset-on-fork -b --batch -d --deadline -i --idle -o --other)'{-R,--reset-on-fork}'[set SCHED_RESET_ON_FORK for FIFO or RR]' \ + '(H)*::command or priority:->cmd_or_prio' \ + + 'H' \ + '(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \ '(* -)'{-h,--help}'[display usage information]' \ '(* -)'{-V,--version}'[output version information]' \ - {-v,--verbose}'[display status information]' \ - {-p,--pid}'[interpret args as process ID]' \ - '(-b --batch -f --fifo -o --other -r --rr)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \ - '(-b --batch -f --fifo -o --other -r --rr)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \ - '(-b --batch -f --fifo -o --other -r --rr)'{-o,--other}'[set policy scheduling policy to SCHED_OTHER]' \ - '(-b --batch -f --fifo -o --other -r --rr)'{-r,--rr}'[set scheduling policy to SCHED_RR]' \ - '(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \ - '*::command or priority:->cmd_or_prio' \ - && return 0 + + 'dline' \ + '(H -T --sched-runtime -b --batch -f --fifo -i --idle -o --other -r --rr)'{-T,--sched-runtime}'[runtime parameter for DEADLINE]' \ + '(H -P --sched-period -b --batch -f --fifo -i --idle -o --other -r --rr)'{-P,--sched-period}'[period parameter for DEADLINE]' \ + '(H -D --sched-deadline -b --batch -f --fifo -i --idle -o --other -r --rr)'{-D,--sched-deadline}'[deadline parameter for DEADLINE]' \ + + '(policy)' \ + '(H dline -R --reset-on-fork)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \ + '(H -R --reset-on-fork)'{-d,--deadline}'[set scheduling policy to SCHED_DEADLINE]' \ + '(H dline)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \ + '(H dline -R --reset-on-fork)'{-i,--idle}'[set scheduling policy to SCHED_IDLE]' \ + '(H dline -R --reset-on-fork)'{-o,--other}'[set scheduling policy to SCHED_OTHER]' \ + '(H dline)'{-r,--rr}'[set scheduling policy to SCHED_RR (default)]' && ret=0 _chrt_priority() { - local ty - if (( $+opt_args[-b] || $+opt_args[--batch] )) - then - ty=BATCH - elif (( $+opt_args[-f] || $+opt_args[--fifo] )) - then - ty=FIFO - elif (( $+opt_args[-o] || $+opt_args[--other] )) - then - ty=OTHER - else - ty=RR - fi - local range - range=${${"$(_call_program priorities chrt --max)"#*SCHED_$ty*: }%$'\n'*} - if [[ $range = 0/0 ]] - then - compadd 0 - else - _message -e priority "priority in the range $range" - fi + local ty + [[ -prefix - ]] && return 1 + if (( $+opt_args[policy--b] || $+opt_args[policy---batch] )); then + ty=BATCH + elif (( $+opt_args[policy--f] || $+opt_args[policy---fifo] )); then + ty=FIFO + elif (( $+opt_args[policy--o] || $+opt_args[policy---other] )); then + ty=OTHER + else + ty=RR + fi + local range + range=${${(M)${(f)"$(_call_program priorities $cmd --max)"}:#*_${ty}*}#*: } + if [[ $range = 0/0 ]]; then + _wanted priorites expl 'priority' compadd 0 + else + _message -e priorities "priority (range $range)" + fi } if (( $+opt_args[-p] || $+opt_args[--pid] )) then - if [[ $CURRENT -eq 1 ]] - then - _alternative \ - 'priority:priority:_chrt_priority' \ - 'processes:process IDs:_pids' - else - _pids - fi -elif [[ $CURRENT -eq 1 ]] -then - _chrt_priority + if (( CURRENT == 1 )); then + _alternative \ + 'priority:priority:_chrt_priority' \ + 'processes:process IDs:_pids' && ret=0 + else + _pids && ret=0 + fi +elif (( CURRENT == 1 )); then + _chrt_priority && ret=0 else - shift words - (( CURRENT-- )) - _normal + shift words + (( CURRENT-- )) + _normal && ret=0 fi + +return ret diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice index a3d49ec99..d64f1c496 100644 --- a/Completion/Linux/Command/_ionice +++ b/Completion/Linux/Command/_ionice @@ -1,12 +1,35 @@ #compdef ionice -_arguments \ - '(* -)-h[display usage information]' \ - '(*)-p[interpret args as process ID]:pid:_pids' \ - '-c+[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \ - '-n+[scheduling class priority]:class-priority:(( +local curcontext="$curcontext" state line expl ret=1 +local -A opt_args + +_arguments -C -s -S \ + '(H -c --class)'{-c+,--class=}'[scheduling class]:class:((0\:none 1\:realtime 2\:best-effort 3\:idle))' \ + '(H -m --classdata)'{-n+,--classdata=}'[scheduling class priority]:class-priority:(( 0\:high\ priority {6..1}\: 7\:low\ priority ))' \ - '*::command:_normal' + '(H -t --ignore)'{-t,--ignore}'[ignore failures]' \ + '(H)*:: :->args' \ + + 'H' \ + '(- *)'{-V,--version}'[display version information]' \ + '(- *)'{-h,--help}'[display help information]' \ + + '(args)' \ + '(H)'{-p-,--pid=-}'[interpret args as process ID]::process id:_pids' \ + '(H)'{-P-,--pgid=-}'[specify process group IDs]::process group' \ + '(H)'{-u-,--uid=-}'[act on running process owned by specified users]::user id' && ret=0 + +if [[ -n $state ]]; then + if (( $+opt_args[args--p] || $+opt_args[args---pid] )); then + _pids && ret=0 + elif (( $+opt_args[args--P] || $+opt_args[args---pgid] )); then + _message -e pgids 'process group' + elif (( $+opt_args[args--u] || $+opt_args[args---uid] )); then + _message -e uids 'user id' + else + _normal && ret=0 + fi +fi + +return ret diff --git a/Completion/Linux/Command/_losetup b/Completion/Linux/Command/_losetup index 359a9e0ea..05ef7c56c 100644 --- a/Completion/Linux/Command/_losetup +++ b/Completion/Linux/Command/_losetup @@ -1,28 +1,44 @@ -#compdef losetup -# based on util-linux 2.26.2 +#lcompdef losetup -value-,LOOPDEV_DEBUG,-default- -_arguments -S -A '-*' \ - '(-l --list)'{-l,--list}'[list currently used loop devices]' \ - '(-n --noheadings)'{-n,--noheadings}'[do not print heading for --list output]' \ - '(-d --delete --detach -o --offset -a --all)'{-o,--offset}'+[specify data start is offset]:offset (bytes)' \ - '(-O --output)'{-O,--output}'[specify columns to be printed with --list]:column: _values -s , column name sizelimit offset autoclear ro back-file' \ - '(-P --partscan)'{-P,--partscan}'[scan the partition table of newly created loop devices]' \ - '--raw[raw output format]' \ - '(-r --read-only)'{-r,--read-only}'[set up a read-only loop device]' \ +if [[ $service = *LOOPDEV_DEBUG* ]]; then + local expl + _wanted values expl value compadd all + return +fi + +local device offset + +device='1:device:_files -g "/dev/loop<->"' +offset=( {-o,--offset}'+[specify data start is offset]:offset (bytes)' ) + +_arguments -s -S \ + - '(H)'\ + {-V,--version}'[display version information]' \ + {-h,--help}'[display help]' \ + - 'info' \ '(-v --verbose)'{-v,--verbose}'[verbose mode]' \ - '(-V --version)'{-V,--version}'[display version information]' \ - '(-h --help)'{-h,--help}'[display help]' \ - '1:device:_files -g "/dev/loop<->"' \ - '(-d --delete --detach)2:file:_files' \ - - '(set1)' \ - '(-o --offset)'{-a,--all}'[show the status of all loop devices]' \ - - '(set2)' \ - {-c,--set-capacity}'[reread the size of the file associated with the loop device]' \ - - '(set3)' \ - '(- 2)'{--delete,--detach,-d}'[detach from specified loop device]' \ - - '(set4)' \ - '(-D --detach-all)'{-D,--detach-all}'[detach all associated loop devices]' \ - - '(set5)' \ - {-f,--find}'[find the first unused loop device]' \ - - '(set6)' \ - {-j,--associated}'[show the status of all loop devices associated with an file]: : _files' + '(-o --offset -a --all)'{-a,--all}'[show the status of all loop devices]' \ + '(-O --output)'{-O+,--output=}'[specify columns to be printed with --list]:column:_sequence -s , compadd - name autoclear back-file back-ino back-maj\:min maj\:min offset partscan ro sizelimit dio' \ + '(-J --json --raw -O --output -n --noheadings)'{-J,--json}'[use JSON --list output format]' \ + '(-l --list)'{-l,--list}'[list currently used loop devices]' \ + '(-J --json)--raw[raw output format]' \ + '(-n --noheadings -J --json)'{-n,--noheadings}"[don't print headings in --list output]" \ + - '(resize)' \ + {-c,--set-capacity}'[reread the size of the file associated with the loop device]' \ + - 'detach' \ + '(-)'{--delete,--detach,-d}'[detach from specified loop device]' \ + "$device" \ + - '(detach-all)' \ + {-D,--detach-all}'[detach all associated loop devices]' \ + - 'create' \ + '--direct-io[open backing file with O_DIRECT]::enable:(on off)' \ + '(-f --find 2)'{-f,--find}'[find the first unused loop device]' \ + '(-L --nooverlap)'{-L,--nooverlap}'[avoid possible conflict between devices]' \ + '(-P --partscan)'{-P,--partscan}'[scan the partition table of newly created loop devices]' \ + '--sizelimit[limit device to specified size]:size (bytes)' \ + '--show[print device name after setup]' \ + '(-r --read-only)'{-r,--read-only}'[set up a read-only loop device]' \ + '1:file:_files' \ + - 'assoc' \ + '(-j --associated)'{-j,--associated}'[show the status of all loop devices associated with an file]:associated file:_files' \ + "(-f)$device" diff --git a/Completion/Linux/Command/_wipefs b/Completion/Linux/Command/_wipefs new file mode 100644 index 000000000..6e8507978 --- /dev/null +++ b/Completion/Linux/Command/_wipefs @@ -0,0 +1,15 @@ +#compdef wipefs + +_arguments -s -S \ + '(H -a --all)'{-a,--all}'[wipe all magic strings]' \ + '(H -b --backup)'{-b,--backup}'[create a signature backup in $HOME]' \ + '(H -f --force)'{-f,--force}'[force erasure]' \ + '(H -n --no-act)'{-n,--no-act}'[do everything except the actual write() call]' \ + '(H -o --offset)'{-o+,--offset=}'[specify offset to erase]:offset (bytes)' \ + '(H -p --parsable)'{-p,--parsable}'[print out in parsable instead of printable format]' \ + '(H -q --quiet)'{-q,--quiet}'[suppress output messages]' \ + '(H -t --types)'{-t+,--types=}'[limit the set of filesystem, RAIDs or partition tables]:type:_file_systems' \ + '(H)*:disk device:_files -g "*(-%)" -P / -W /' \ + + '(H)' \ + '(- *)'{-h,--help}'[display help information]' \ + '(- *)'{-V,--version}'[display version information]' .