summaryrefslogtreecommitdiff
path: root/Completion/BSD/Command/_sockstat
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2015-11-25 18:51:00 +0100
committerAxel Beckert <abe@deuxchevaux.org>2015-11-25 18:51:00 +0100
commit317ec32cb1cbd15b31e17bcb07f09c52cd37c44a (patch)
tree88a02c853dfafd82a2d551d862d8dfb056b1bee6 /Completion/BSD/Command/_sockstat
parent1637291aaea12ddcfd549d50d49c480185995c1a (diff)
parentcce4261a3c6f4bf78b483db61623c80e3c98d10b (diff)
downloadzsh-317ec32cb1cbd15b31e17bcb07f09c52cd37c44a.tar.gz
zsh-317ec32cb1cbd15b31e17bcb07f09c52cd37c44a.zip
Merge tag 'zsh-5.1.1-test-1' into debian
Diffstat (limited to 'Completion/BSD/Command/_sockstat')
-rw-r--r--Completion/BSD/Command/_sockstat61
1 files changed, 42 insertions, 19 deletions
diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat
index e61854622..daad946fc 100644
--- a/Completion/BSD/Command/_sockstat
+++ b/Completion/BSD/Command/_sockstat
@@ -1,23 +1,46 @@
#compdef sockstat
+local -a args protocols
+local proto
-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*)
+ for proto in ${${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]*}}; do
+ case $proto in
+ *\#*)
+ protocols+=(${${${(j: :)${(q)=proto}}// *\# /\[}/%/\]})
+ ;;
+ *)
+ protocols+=(${${(j: :)${=proto}}// */})
+ esac
+ done
-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
-}
+ args+=(
+ '*-j[show sockets belonging to JID]: : _jails -0 -o jid'
+ '-L[exclude loopback]'
+ '*-P+[specify protocol]: : _values -s , protocols $protocols'
+ )
+ ;;
+ netbsd*)
+ args+=(
+ '*-f+[only show specified address family]:address family:(inet inet6 local unix)'
+ '-n[no symbolic names for addresses/ports]'
+ )
+ ;;
+esac
-_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))'
+if (( $#args )); then
+ _arguments -s -w : $args
+ return
+fi
+
+_default