zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _sockstat: update sockstat(1)
@ 2015-10-18 19:52 Eric Cook
  0 siblings, 0 replies; only message in thread
From: Eric Cook @ 2015-10-18 19:52 UTC (permalink / raw)
  To: zsh-workers

for misc BSDs like DragonflyBSD, show a common subset of options.
For FreeBSD, complete jail ids for -j. And added netbsd specific options

---
 Completion/BSD/Command/_sockstat | 50 +++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat
index e618546..1b11ba4 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
-- 
2.6.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-18 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-18 19:52 [PATCH] _sockstat: update sockstat(1) Eric Cook

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).