summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2017-10-11 01:23:59 +0200
committerOliver Kiddle <opk@zsh.org>2017-10-11 01:23:59 +0200
commita8c2b908107fb658e3859ce8f3d61f2c31354227 (patch)
tree3b285db7591909c005a1fdf4c98f25c35855ef78 /Completion/Unix/Command
parentea7178a6242db104b69a4e6cc2d4d4020cb736f6 (diff)
downloadzsh-a8c2b908107fb658e3859ce8f3d61f2c31354227.tar.gz
zsh-a8c2b908107fb658e3859ce8f3d61f2c31354227.tar.xz
zsh-a8c2b908107fb658e3859ce8f3d61f2c31354227.zip
41854: also complete options for ping on Solaris, Mac OS, NetBSD and OpenBSD and for ping6
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_ping271
1 files changed, 205 insertions, 66 deletions
diff --git a/Completion/Unix/Command/_ping b/Completion/Unix/Command/_ping
index a1a50e11f..2efe545c6 100644
--- a/Completion/Unix/Command/_ping
+++ b/Completion/Unix/Command/_ping
@@ -1,69 +1,208 @@
-#compdef ping
+#compdef ping ping6
 
-if _pick_variant iputils=iputils unix -V; then
-              
-  _arguments \
-    '-a[audible]' \
-    '-A[adaptive]' \
-    '-b[allow pinging a broadcast address]' \
-    '-B[do not allow ping to change source address]' \
-    '-c:count' \
-    '-d[set SO_DEBUG on the socket]' \
-    '-f[flood ping]' \
-    '-i:interval in seconds' \
-    '-I:iface:_net_interfaces' \
-    '-l:preload number' \
-    '-L[suppress loopback of multicast packets]' \
-    '-n[numeric output only]' \
-    '-p:padding pattern' \
-    '-Q:QoS TOS bits' \
-    '-q[quiet]' \
-    '-r[bypass normal routing tables]' \
-    '-R[record route]' \
-    '-s:packet size in bytes' \
-    '-S:sndbuf' \
-    '-t:timeout in seconds' \
-    '-T:timestamp option:(tsonly tsandaddr tsprespec)' \
-    '-M:Path MTU Discovery strategy:((do\:prohibit\ fragmentation want\:fragment\ locally dont\:do\ not\ set\ DF\ flag))' \
-    '-U[print full user-to-user latency]' \
-    '-v[verbose]' \
-    '-w:deadline in seconds' \
-    '-W:seconds to wait for a response' \
-    ':host:_hosts'
-
-else
+local variant
+local -a args
 
-  _arguments \
-    '-A[audible for no packet]' \
-    '-a[audible for each packet]' \
-    '-c:count' \
-    "-D[set the don't fragment bit]" \
-    '-d[set SO_DEBUG on the socket]' \
-    '-f[flood ping]' \
-    '-G[specify maximum size for ICMP payload for sweeping pings]:size' \
-    '-g[specify minimum size for ICMP payload for sweeping pings]:size [0]' \
-    '-h[specify size increment for ICMP payload for sweeping pings]:size [1]' \
-    '-i:wait seconds' \
-    '-I[source interface for multicast packets]:iface:_net_interfaces' \
-    '-L[suppress loopback of multicast packets]' \
-    '-l:preload number' \
-    '-M:icmp:(mask time)' \
-    '-m:ttl' \
-    '-n[numeric output only]' \
-    '-o[exit after receiving one packet]' \
-    '-P:IPsec policy' \
-    '-p:padding pattern' \
-    '-Q[somewhat quiet]' \
-    '-q[quiet]' \
-    '-R[record route]' \
-    '-r[bypass normal routing tables]' \
-    '-S:source address' \
-    '-s:packet size in bytes' \
-    '-T:ttl for multicasted packets' \
-    '-t:timeout in seconds' \
-    '-v[verbose]' \
-    '-W:wait time (ms)' \
-    '-z:type of service' \
-    ':host:_hosts'
+_pick_variant -r variant iputils=iputils $OSTYPE -V
+              
+case ${variant}:${${service#ping}:-4} in
+  iputils*) args=( -A "-*" ) ;|
+  *)
+    args+=(
+      '-d[set SO_DEBUG on the socket]'
+      '-n[show network addresses as numbers]'
+      '-v[verbose output]'
+    )
+  ;|
+  iputils*|aix*|*bsd*|darwin*|dragonfly*)
+    args+=(
+      '-c+[specify number of packets to send]:count'
+      '-f[flood ping]'
+      '-i+[specify delay between packets]:interval (seconds) [1]'
+      '-l+[send specified number of initial packets as fast as possible]:number of packets'
+      '-p+[specify pad bytes to fill sent packet with]:padding pattern'
+      '-q[quiet]'
+      '-s+[specify packet size]:size (bytes) [56]'
+    )
+  ;|
+  iputils:*|solaris:*|(*bsd|darwin|dragonfly)*:4)
+    args+=(
+      '-L[disable loopback of multicast packets]'
+      '-R[record route]'
+    )
+  ;|
+  iputils:*|solaris:*|((free|net)bsd|darwin|dragonfly)*:4)
+    args+=( '-r[bypass normal routing tables]' )
+  ;|
+  iputils:*|((free|net)bsd|darwin|dragonfly)*:4)
+    args+=( '-a[audible bell for each packet]' )
+  ;|
+  iputils:*|(net|open)bsd*:4)
+    args+=( '-w+[specify timeout after which ping exits]:deadline (seconds)' )
+  ;|
+  iputils:*|openbsd*:4|solaris*)
+    args+=(
+      '-t+[set IP Time to Live for outgoing packets]:ttl'
+    )
+  ;|
+  (*bsd|darwin|dragonfly)*)
+    args+=( '-I+[specify source interface for multicast packets]:interface:_net_interfaces' )
+  ;|
+  freebsd*|darwin*|dragonfly*|netbsd*:6)
+    args+=( '-S+[specify source address]:source address' )
+  ;|
+  freebsd*|darwin*|dragonfly*:4|netbsd*:4)
+    args+=( '-o[exit after receiving one packet]' )
+  ;|
+  (*bsd|darwin|dragonfly)*:4)
+    args+=( "-D[set the don't fragment bit]" )
+  ;|
+  ((free|net)bsd|darwin|dragonfly)*:4)
+    args+=(
+      '-Q[somewhat quiet]'
+      '-T+[set IP Time to Live for outgoing packets]:ttl'
+    )
+  ;|
+  freebsd*:6|darwin*:6|solaris*|netbsd*)
+    args+=(
+      '*-g+[specify gateway to use as the next hop to the destination]:gateway:_hosts'
+    )
+  ;|
+  (*bsd|darwin|dragonfly)*:6)
+    args+=( '-h+[set the IPv6 hoplimit]:hop limit' )
+  ;|
+  ((free|net)bsd|darwin|dragonfly)*:6)
+    args+=(
+      '-a+[generate ICMPv6 Node Information Node Addresses query]:address type:(a c g s l A)'
+      '-b+[set socket buffer size]:buffer size'
+      '-H[try reverse-lookups of IPv6 addresses]'
+      '-N[probe node information multicast group address]'
+      '(-s)-t[generate ICMPv6 Node Information supported query types query]'
+      '(-s)-w[generate ICMPv6 Node Information DNS Name query]' '!(-s)-W'
+    )
+  ;|
+  (*bsd|darwin)*:6)
+    args+=( '*-m[suppress fragmenting of packets into the minimum IPv6 MTU]' )
+  ;|
+  freebsd*|darwin*|dragonfly*|netbsd*:6)
+    args+=( '-P+[specify IPsec policy to be used for the probe]:policy' )
+  ;|
+  solaris2.<11->)
+    args+=(
+      '-b[bypass global IPsec policy and send and receive packets in the clear]'
+      '-N+[specify a next-hop router that the probe packet should go through]:router:_hosts'
+    )
+  ;|
+  (freebsd|darwin|dragonfly)*:4)
+    args+=(
+      '-A[audible bell for no packet]'
+      '-G+[specify maximum size for ICMP payload for sweeping pings]:size'
+      '-g+[specify minimum size for ICMP payload for sweeping pings]:size [0]'
+      '-h+[specify size increment for ICMP payload for sweeping pings]:size [1]'
+      '-M+[use ICMP_MASKREQ or ICMP_TSTAMP instead of ICMP_ECHO]:ICMP:(mask time)'
+      '-m+[set IP Time to Live for outgoing packets]:ttl'
+      '-t+[specify timeout after which ping exits]:deadline (seconds)'
+      '-W+[specify time to wait for a response]:wait time (ms)'
+      '-z+[specify type of service]:type of service'
+    )
+  ;;
+  (freebsd|darwin)*:6)
+    args+=(
+      '-R[audible bell for no packet]'
+      '-r[audible bell for each packet]'
+    )
+  ;;
+  freebsd*:6)
+    args+=(
+      '-x+[specify time to wait for a response]:wait time (ms)'
+      '-X+[specify timeout after which ping exits]:deadline (seconds)'
+    )
+  ;;
+  netbsd*:4)
+    args+=(
+      '-C[send timestamps in compat format]'
+      '-E+[specify IPsec policy to be used for the probe]:policy'
+      '-h+[specify target host]:host:_hosts'
+      '-P+[use a pseudo-random sequence for the data]'
+      '-t+[specify type of service]:type of service'
+    )
+  ;;
+  (dragonfly|netbsd)*:6)
+    args+=( '-R[inject reachability confirmation hint for target host/first hop]' )
+  ;|
+  darwin*:4)
+    args+=( '-b+[bind the socket to specified interface for sending]:interface:_net_interfaces' )
+  ;|
+  darwin*:6)
+    args+=(
+      '-B+[bind the socket to specified interface for sending]:interface:_net_interfaces'
+      '-C[prohibit socket from using cellular network interface]'
+    )
+  ;|
+  darwin*)
+    args+=(
+      '-k+[specify traffic class to use for sending ICMP packets]:traffic class [CTL]:(BK_SYS BK BE RD OAM AV RV VI VO CTL)'
+    )
+  ;;
+  openbsd*:4)
+    args+=(
+      '-T+[change TOS value]:TOS value:(critical inetcontrol lowdelay netcontrol throughput reliability ef af cs)'
+    )
+  ;|
+  openbsd*)
+    args+=(
+      '-H[try reverse-lookups of addresses]'
+      '-E[audible bell for no packet]'
+      '-e[audible bell for each packet]'
+      '-V+[specify routing table to be used]:routing table'
+    )
+  ;;
+  iputils:4)
+    args+=(
+      '(-F -N)-4[use IPv4 only]'
+      '-6[use IPv6 only]'
+    )
+  ;|
+  iputils:*)
+    args+=(
+      '-A[adaptive]'
+      '-b[allow pinging a broadcast address]'
+      "-B[don't allow ping to change source address]"
+      '-D[print timestamp before each line]'
+      '(-4)-F+[allocate and set 20-bit flow label]:flow label (hex)'
+      '(-)-h[show usage information]'
+      '-I+[specify source interface]:interface:_net_interfaces'
+      '-m+[specify mark to tag outgoing packets]:mark'
+      "-M+[specify path MTU discovery strategy]:strategy:((
+        do\:prohibit\ fragmentation,\ even\ local\ one
+	want\:do\ PMTU\ discovery
+	dont\:don\'t\ set\ DF\ flag))"
+      '(-4)-N+[send ICMPv6 node information queries instead of echo request]:sub option'
+      '-O[report outstanding ICMP ECHO reply before sending next packet]'
+      '-Q+[set Quality of Service-related bits in ICMP datagrams]:QoS TOS bits'
+      '-S+[set socket sndbuf]:sndbuf'
+      '-T+[set special IP timestamp options]:timestamp option:(tsonly tsandaddr tsprespec)'
+      '-U[print full user-to-user latency]'
+      '(-)-V[display version information]'
+      '-W+[specify time to wait for a response]:wait time (seconds)'
+    )
+  ;;
+  solaris*)
+    args+=(
+      '-A+[specify address family]:address family:(inet inet6)'
+      '-F+[specify the flow label of probe packets]:number'
+      '-I+[specify delay between packets]:interval (seconds) [1]'
+      '-P+[specify type of service]:type of service (0-255) [0]'
+      '-U[send UDP packets instead of ICMP]'
+      '-a[ping all addresses, both IPv4 and IPv6 of multihomed destination]'
+      '-c+[specify the traffic class of probe packets]:traffic class (0-255)'
+      '-i+[specify source interface]:interface:_net_interfaces'
+      '-l[send the probe using loose source routing]'
+      '-p+[set base UDP port]:port [33434]'
+      '-s[send one datagram per second and collect statistics]'
+    )
+  ;;
+esac
 
-fi
+_arguments -s -S $args \
+  '*:host:_hosts'