about summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2018-10-31 19:14:05 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2018-10-31 19:17:59 +0900
commit967c964e214ff5852a105ca84de247a4e88cc274 (patch)
tree283791fd99f6ce542cff866793df4057b1fdd329 /Completion/Unix/Command
parent73b1328049c37a8d7d789fb7d6b7e679ee73ba48 (diff)
downloadzsh-967c964e214ff5852a105ca84de247a4e88cc274.tar.gz
zsh-967c964e214ff5852a105ca84de247a4e88cc274.tar.xz
zsh-967c964e214ff5852a105ca84de247a4e88cc274.zip
43744: _sysctl: support procps-ng, NetBSD
with several updates for other OS
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_sysctl88
1 files changed, 58 insertions, 30 deletions
diff --git a/Completion/Unix/Command/_sysctl b/Completion/Unix/Command/_sysctl
index c5bb26eb0..2bdcc71f5 100644
--- a/Completion/Unix/Command/_sysctl
+++ b/Completion/Unix/Command/_sysctl
@@ -1,20 +1,50 @@
 #compdef sysctl
 
-local -a args
+local -a args sysctlvars
 
 case $OSTYPE in
+  linux*)
+    args=(
+      {-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=}'[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=procps-ng procps --version; then
+      args+=(
+	'--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=}'[only apply to variables matching specified pattern]:extended regexp'
+      )
+    else
+      args=( ${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<11->.*)
+    args+=(
+      '-B[specify buffer size for reading]:buffer size'
+      '-t[display type of variable]'
+    )
+  ;|
   freebsd<10->.*)
     args+=(
       '-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+=( "-i[silently exit if variable doesn't exist]" )
+  darwin*|freebsd*)
+    args+=( '-h[format output for human readability]' )
   ;|
-  freebsd*)
-    local -a sysctlvars
+  darwin*|dragonfly*|freebsd*)
     sysctlvars=( $(_call_program sysctl-variables sysctl -aN) )
     _arguments -s -S -A "-*" $args \
       '(-a -o *)-A[equivalent to -o -a (for compatibility)]' \
@@ -22,43 +52,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 =]' \
-      '-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:=${${$(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=} -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 = -q . sysctlvars'
   ;;
   openbsd*)
-    : ${(A)_cache_sysctlvars:=${${${(f)"$(sysctl -a 2>/dev/null)"}%%=*}:# *}}
+    sysctlvars=( ${${${(f)"$(_call_program sysctl-variables
+				sysctl -a 2>/dev/null)"}%%=*}:# *} )
     _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 = -q . _cache_sysctlvars'
+      '*:sysctl variable:_multi_parts -i -S = -q . sysctlvars'
+  ;;
+  netbsd*)
+    sysctlvars=( ${${${(f)"$(_call_program sysctl-variables
+				sysctl -a 2>/dev/null)"}%% =*}%%:*} )
+    _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 =]' \
+      '(-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=} -i . sysctlvars'
   ;;
   *)
     _default