summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorEric Cook <llua@gmx.com>2015-10-19 11:33:17 +0200
committerOliver Kiddle <opk@zsh.org>2015-10-19 11:33:17 +0200
commitd8f8d3e5340e4f61e70aef68d20a41db4445a66f (patch)
treecd19763dbb948e679c4cdef32da4ff80103e1966 /Completion
parent509c822b626c01e0787aac2baef5af80d15da529 (diff)
downloadzsh-d8f8d3e5340e4f61e70aef68d20a41db4445a66f.tar.gz
zsh-d8f8d3e5340e4f61e70aef68d20a41db4445a66f.tar.xz
zsh-d8f8d3e5340e4f61e70aef68d20a41db4445a66f.zip
36889: completion of system specific sockstat options
Diffstat (limited to 'Completion')
-rw-r--r--Completion/BSD/Command/_sockstat50
1 files changed, 31 insertions, 19 deletions
diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat
index e61854622..1b11ba473 100644
--- a/Completion/BSD/Command/_sockstat
+++ b/Completion/BSD/Command/_sockstat
@@ -1,23 +1,35 @@
 #compdef sockstat
+local -a args
 
-local tmp_proto protocols proto
+case $OSTYPE in
+  *bsd*)
+    args=(
+      '-4[show AF_INET (IPv4) sockets]'
+      '-6[show AF_INET6 (IPv6) sockets]'
+      '-c[show connected sockets]'
+      '-l[show listening sockets]'
+      '*-p[specify port number]:port numbers (comma delimited)'
+      '-u[show AF_LOCAL (UNIX) sockets]'
+    )
+  ;|
+  freebsd*)
+    args+=(
+      '*-j[show sockets belonging to JID]: : _jails -0 -o jid'
+      '-L[exclude loopback]'
+      '*-P[specify protocol]: :_sequence -s , _ports'
+    )
+  ;;
+  netbsd*)
+    args+=(
+      '*-f[only show specified address family]:address family:(inet inet6 local unix)'
+      '-n[no symbolic names for addresses/ports]'
+    )
+  ;;
+esac
 
-tmp_proto=(${${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]*}})
-for proto ($tmp_proto) {
-	case $proto in
-	*\#*)
-		protocols=($protocols ${${(j: :)${=proto}}// *\# /:})
-		;;
-	*)
-		protocols=($protocols ${${(j: :)${=proto}}// */})
-	esac
-}
+if (( $#args )); then
+  _arguments -s -w $args
+  return
+fi
 
-_arguments -s \
-	'-4[show AF_INET (IPv4) sockets]' \
-	'-6[show AF_INET6 (IPv6) sockets]' \
-	'-c[show connected sockets]' \
-	'-l[show listening sockets]' \
-	'-u[show AF_LOCAL (UNIX) sockets]' \
-	'-p[only show Internet sockets if the port number is on the specified list]' \
-	'-P[only show sockets of the specified protocols]:protocols:(($protocols))'
+_default