From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43742-ml=inbox.vuxu.org@zsh.org 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 116585ee for ; Mon, 29 Oct 2018 08:54:26 +0000 (UTC) Received: (qmail 4215 invoked by alias); 29 Oct 2018 08:54:12 -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: 43742 Received: (qmail 24448 invoked by uid 1010); 29 Oct 2018 08:54:12 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-mqugw.biglobe.ne.jp 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(133.208.100.2):SA:0(-2.6/5.0):. Processed in 3.218713 secs); 29 Oct 2018 08:54:12 -0000 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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.0 \(3445.100.39\)) Subject: [PATCH] update _sysctl Message-Id: <48A17756-C4ED-4B31-B2E3-541E94BA94A4@kba.biglobe.ne.jp> Date: Mon, 29 Oct 2018 17:53:30 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3445.100.39) X-Biglobe-Spnum: 63406 Add support for procps-ng on Linux (and update procps variant). Add support for NetBSD. Update Darwin/DragonFly No change for FreeBSD (except for fixing a typo). Before the patch, sysctlvars was cached in Darwin, DragonFly and OpenBSD = (but not in FreeBSD). I removed the caching but I couldn't notice any slowing = down. I hope this is OK. diff --git a/Completion/Unix/Command/_sysctl = b/Completion/Unix/Command/_sysctl index c5bb26eb0..a2a7e3eb9 100644 --- a/Completion/Unix/Command/_sysctl +++ b/Completion/Unix/Command/_sysctl @@ -1,20 +1,44 @@ #compdef sysctl =20 -local -a args +local -a args sysctlvars =20 case $OSTYPE in + linux*) + args=3D( + {-e,--ignore}'[ignore errors about unknown keys]' + '(-n -N --names)'{-N,--names}'[show only variable names]' + '(-N -n --values)'{-n,--values}'[show only variable values]' + '(-)'{-w,--write}'[write mode]' + '(-A -a -w --system *)'{-p,--load=3D}'[specify file to load = sysctl settings from]:file (can be regexp):_files' + {-q,--quiet}'[do not display names and values when setting = variables]' + '(-e --ignore -w --write -A -a --all *)'{-A,-a,--all}'[display = all variables]' + ) + if _pick_variant ng=3Dprocps-ng procps --version; then + args+=3D( + '--deprecated[include deprecated parameters in --all listing]' + {-b,--binary}'[print value without new line]' + '(-p --load)--system[load settings from all system config = files]' + {-r+,--pattern=3D}'[only apply to variables matching specified = pattern]:extended regexp' + ) + else + args=3D( ${args:#((#s)|*\))(\*|)--*} ) # remove long options + fi + _arguments -S -A "-*" : $args \ + '(- :)'{-h,--help}'[display help text and exit]' \ + '(- :)'{-V,--version}'[display version info and exit]' \ + '*:sysctl variable:_files -W /proc/sys' + ;; freebsd<10->.*) args+=3D( '-f+[specify file of name/value pairs to process = first]:file:_files' - '-T[display only variables that are setable via loader]' + '-T[display only variables that are settable via loader]' '-W[display only writable variables that are not statistical]' ) ;| - dragonfly*|freebsd*) - args+=3D( "-i[silently exit if variable doesn't exist]" ) + darwin*|freebsd*) + args+=3D( '-h[format output for human readability]' ) ;| - freebsd*) - local -a sysctlvars + darwin*|dragonfly*|freebsd*) sysctlvars=3D( $(_call_program sysctl-variables sysctl -aN) ) _arguments -s -S -A "-*" $args \ '(-a -o *)-A[equivalent to -o -a (for compatibility)]' \ @@ -22,43 +46,41 @@ case $OSTYPE in '-b[binary output]' \ '-d[print the description of the variable instead of its value]' = \ '(-N -n)-e[separate name and value with =3D]' \ - '-h[format output for human readability]' \ + "-i[silently exit if variable doesn't exist]" \ '(-n)-N[show only variable names]' \ '(-N)-n[show only variable values]' \ '(-x)-o[show opaques as well (values suppressed)]' \ '-q[suppress some warnings]' \ '(* -o)-X[equivalent to -x -a (for compatibility)]' \ '(-o)-x[show opaques as well (entire values)]' \ - '(-a)*:sysctl variable:_multi_parts -i . sysctlvars' - ;; - darwin*|dragonfly*) - : ${(A)_cache_sysctlvars:=3D${${$(sysctl -A = 2>/dev/null):#[^a-z]*}%%:*}} - _arguments -s -A "-*" $args \ - '(-w -X *)-a[list all]' \ - '(-w -X *)-A[show all opaques (values suppressed)]' \ - '(-w)-b[binary output]' \ - '(-w)-n[show only variable values]' \ - '(-a -A -b -n -X)-w[write mode]' \ - '(-a -A -w *)-X[show all opaques (entire values)]' \ - '(-a -A -X)*:sysctl variable:_multi_parts ${words[(r)-w]:+-S=3D} = -i . _cache_sysctlvars' - ;; - linux*) - _arguments -A "-*" \ - '-n[show only variable values]' \ - '(-n -p -a -A)-w[write mode]' \ - '(-n -w -a -A *)-p[specify file to load sysctl settings = from]:file:_files' \ - '(-n -w -p -A *)-a[list all]' \ - '(-n -w -p -a *)-A[list all in table form]' \ - '(-n -p -a -A)*:sysctl variable:_files -W /proc/sys' + '*:sysctl variable:_multi_parts -i -S =3D -q . sysctlvars' ;; openbsd*) - : ${(A)_cache_sysctlvars:=3D${${${(f)"$(sysctl -a = 2>/dev/null)"}%%=3D*}:# *}} + sysctlvars=3D( ${${${(f)"$(_call_program sysctl-variables + sysctl -a 2>/dev/null)"}%%=3D*}:# *} ) _arguments -S -s -A "-*" \ '(-A -q *)-a[list all string and integer variables]' \ '(-a -q *)-A[list all known variables]' \ '-n[show only values]' \ '(-a -A)-q[suppress all output when setting a variable]' \ - '(-a -A)*:sysctl variable:_multi_parts -i -S =3D -q . = _cache_sysctlvars' + '*:sysctl variable:_multi_parts -i -S =3D -q . sysctlvars' + ;; + netbsd*) + sysctlvars=3D( ${${${(f)"$(_call_program sysctl-variables + sysctl -a 2>/dev/null)"}%% =3D*}%%:*} ) + _arguments -S -s -A "-*" : \ + '(-a -f -M -q -w)-A[list all known variables]' \ + '(-A -f -M -q -w *)-a[list all string and integer variables]' \ + '(-M -w -x)-d[print the description of the variable instead of = its value]' \ + '(-f -M -w)-e[separate name and value with =3D]' \ + '(-a -A -w *)-f[read variable from specified file]:file:_files' \ + '(-a -A -d -r -x -w)-M[print entire MIB instead of just value]' \ + '-n[show only variable values]' \ + '(-A -a -M)-q[silently ignore nonexistent variables]' \ + '(-M -x)-r[binary output]' \ + '(-a -A -d -e -f -M -r)-w[write mode]' \ + '(-d -M -r)*-x[hex output. -xx for hexdupm-like output]' \ + '*:sysctl variable:_multi_parts ${words[(r)-w]:+-S=3D} -i . = sysctlvars' ;; *) _default