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.0 required=5.0 tests=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 66dd4077 for ; Sat, 1 Jun 2019 06:56:31 +0000 (UTC) Received: (qmail 12085 invoked by alias); 1 Jun 2019 06:56:09 -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: 44389 Received: (qmail 9149 invoked by uid 1010); 1 Jun 2019 06:56:09 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-expgw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25461. spamassassin: 3.4.2. Clear:RC:0(133.208.98.1):SA:0(-2.6/5.0):. Processed in 1.544783 secs); 01 Jun 2019 06:56:09 -0000 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf01.biglobe.ne.jp designates 133.208.98.1 as permitted sender) X-Biglobe-Sender: From: "Jun. T" Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [PATCH] update _iostat and _vmstat for BSD Message-Id: Date: Sat, 1 Jun 2019 15:55:30 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.104.8) X-Biglobe-Spnum: 7738 _iostat contained an action '->devicetype' but didn't have the handler = for it. _vmstat had the handler, so I separated it into _fbsd_device_type (with = slight improvements). On the other hand, _vmstat didn't complete disk device names properly on = BSDs. I gathered the corresponding lines from _iostat and put them in = _bsd_disks (and added support for netbsd). Also included a few option updates and fixed a trivial bug (args=3D --> = args+=3D). Linux (and Solaris, AIX) branches are not modified. diff --git a/Completion/BSD/Type/_bsd_disks = b/Completion/BSD/Type/_bsd_disks new file mode 100644 index 000000000..986d36e45 --- /dev/null +++ b/Completion/BSD/Type/_bsd_disks @@ -0,0 +1,26 @@ +#autoload +# disk device names on BSDs +local -a disks + +case $OSTYPE in + freebsd*) + disks=3D( ${${(M)${(f)"$(geom disk list)"}\:#Geom name\:*}#*\: } ) + ;; + dragonfly*) + disks=3D( $(sysctl -n kern.disks) ) + ;; + openbsd*) + disks=3D( ${${(s.,.)"$(sysctl -n hw.disknames)"}%\:*} ) + ;; + netbsd*) + disks=3D( $(sysctl -n hw.disknames) ) + ;; +esac + +if (( $#disks )); then + local expl + _wanted disk-devices expl 'disk device' compadd "$@" $disks + return +fi + +return 1 diff --git a/Completion/BSD/Type/_fbsd_device_types = b/Completion/BSD/Type/_fbsd_device_types new file mode 100644 index 000000000..f1897f6a7 --- /dev/null +++ b/Completion/BSD/Type/_fbsd_device_types @@ -0,0 +1,31 @@ +#autoload +# +# device types on FreeBSD/DragonFly +# (for commands using devstat_buildmatch(), such as iostat and vmstat) +# +local -a d i types + +d=3D( da sa printer proc worm cd scanner optical changer + comm array enclosure floppy) +i=3D( IDE SCSI other ) +types=3D( + "($d)da[direct access devices]" + "($d)sa[sequential access devices]" + "($d)printer[printers]" + "($d)proc[processor devices]" + "($d)worm[write once read multiple devices]" + "($d)cd[CD devices]" + "($d)scanner[scanner devices]" + "($d)optical[optical memory devices]" + "($d)changer[medium changer devices]" + "($d)comm[communication devices]" + "($d)array[storage array devices]" + "($d)enclosure[enclosure services devices]" + "($d)floppy[floppy devices]" + "($i)IDE[Integrated Drive Electronics devices]" + "($i)SCSI[Small Computer System Interface devices]" + "($i)other[any other device interface]" + 'pass[passthrough devices]' +) + +_values -s , 'device type' $types diff --git a/Completion/Unix/Command/_iostat = b/Completion/Unix/Command/_iostat index 8909ae311..f5291a19b 100644 --- a/Completion/Unix/Command/_iostat +++ b/Completion/Unix/Command/_iostat @@ -4,42 +4,53 @@ local -a args parser parser=3D( -s -S -A '-*' ) =20 case $OSTYPE:l in - *bsd*) + *bsd*|dragonfly*) args+=3D( - '-c[repeat the display N times]:count' + '-c+[repeat the display N times]:count' '-C[display CPU statistics]' '-d[display only device statistics]' '-I[display total statistics for a given period, rather than = average]' - '-M[extract values of the name list from specified = file]:core:_files' - '-N[extract the name list from the specified file]:system:_files' '-T[display TTY statistics]' - '-w[specify the duration of pauses between each = display]:duration' + '-w+[specify the duration of pauses between each = display]:duration' + '*: :_bsd_disks' ) ;| - freebsd*) + freebsd*|openbsd*|dragonfly*) + args+=3D( + '-M+[extract values of the name list from specified = file]:core:_files' + '-N+[extract the name list from the specified = file]:system:_files' + ) + ;| + freebsd*|dragonfly*) args+=3D( '-h[top mode]' '-K[display block count in kilobytes, not block size]' + '-n+[display up to the specified number fo devices]:number of = disks' '-o[display old-style iostat device statistics]' - '-t[specify which type of device to display]: :->devicetype' + '*-t+[specify which type of device to display]: = :_fbsd_device_types' + ) + ;| + freebsd*) + args+=3D( '-x[show extended disk statistics]' '-z[omit lines for devices with no activity]' - '-?[display a usage statement and exit]' - '*:drives:( ${${(M)${(f)"$(geom disk list)"}\:#Geom name\:*}#*\: = } )' + '(* -)-?[display a usage statement and exit]' ) ;; - openbsd*) + dragonfly*) args+=3D( - '-D[display alternate disk statistics]' - '*:drives:( ${${(s.,.)"$(sysctl -n hw.disknames)"}%\:*} )' + '-D[display more details]' ) ;; - netbsd*) + openbsd*|netbsd*) args+=3D( '-D[display alternate disk statistics]' + ) + ;| + netbsd*) + args+=3D( '-x[show extended disk statistics]' '-y[report data on waiting and active requests]' - '*:drives:( $(sysctl -n hw.disknames) )' ) ;; aix*) @@ -97,16 +108,17 @@ case $OSTYPE:l in ;; darwin*) args=3D( + '(- *)-?[display usage statement and exit]' '-C[display CPU statistics]' - '-c[number of times to display statistics]' + '-c+[number of times to display statistics]:count' '-d[display only device statistics]' - '-l[total statistics for a given time period]' + '-I[display total statistics for a given period, rather than = average]' '-K[display block count in kilobytes]' - '-n[limit the number of disks included in the report]:number of = disks' + '-n+[limit the number of disks included in the report]:number of = disks' '-o[display old-style iostat device statistics]' '-T[display TTY statistics]' '-U[display system load averages]' - '-w[specify the duration of pauses between each = display]:duration' + '-w+[specify the duration of pauses between each = display]:duration' '*::device:_files -W /dev -g "disk*"' ) ;; diff --git a/Completion/Unix/Command/_vmstat = b/Completion/Unix/Command/_vmstat index bc13a5505..f3ac1af14 100644 --- a/Completion/Unix/Command/_vmstat +++ b/Completion/Unix/Command/_vmstat @@ -28,11 +28,11 @@ case $OSTYPE in '-M+[specify core file to extract values associated with the name = list from]:core:_files' '-N+[specify file to extract the name list from]:system:_files' '-w+[specify delay between each display]:delay (seconds)' - '*:disk:_files' + '*: :_bsd_disks' ) ;| *bsd*) - specs=3D( + specs+=3D( '-f[report on the number fork syscalls since boot and pages of = virtual memory for each]' ) ;| @@ -89,12 +89,6 @@ case $OSTYPE in '-v[include IRQ numbers and IRQ target CPU numbers before device = names (with -i)]' ) ;; - freebsd*|solaris*) - specs+=3D( - '::disk:_files -W /dev -g "*(-%b)"' - ': :_guard "[0-9]#" "interval (seconds)"' ':count' - ) - ;| solaris2.<11->) specs+=3D( '(-i -s)-T+[specify time format]:time = format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) ;& @@ -106,30 +100,20 @@ case $OSTYPE in '-p[report paging activity]' '(-T)-s[display the total number of system events since boot]' '-S[report on swapping rather than paging activity]' + '::disk:_files -W /dev -g "*(-%b)"' + ': :_guard "[0-9]#" "interval (seconds)"' '::count' ) ;; esac =20 if (( $#specs )); then local curcontext=3D$curcontext state state_descr line ret=3D1 - typeset -A {opt,val}_args + typeset -A opt_args =20 _arguments -C -s -w -A '-*' : "$specs[@]" && ret=3D0 =20 if [[ $state =3D=3D devices ]]; then - local -a types - types=3D( - 'da[direct access devices]' 'sa[sequential access devices]' - 'printer[printers]' 'proc[processor devices]' - 'worm[write once read multiple devices]' 'cd[CD devices]' - 'scanner[scanner devices]' 'optical[optical memory devices]' - 'changer[medium changer devices]' 'comm[communication devices]' - 'array[storage array devices]' 'enclosure[enclosure services = devices]' - 'floppy[floppy devices]' 'IDE[Integrated Drive Electronics = devices]' - 'SCSI[Small Computer System Interface devices]' - 'other[any other device interface]' 'pass[passthrough devices]' - ) - _values -s , 'device type' "$types[@]" && ret=3D0 + _fbsd_device_types && ret=3D0 elif [[ $state =3D=3D hashes ]]; then local -a tables tables=3D( ${${${(f)"$(_call_program hashes $words[1] = -L)"}[2,-1]#?}/ ##/:} )