From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7944 invoked by alias); 10 Oct 2017 22:07:37 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41854 Received: (qmail 5151 invoked by uid 1010); 10 Oct 2017 22:07:37 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(-1.7/5.0):. Processed in 2.645653 secs); 10 Oct 2017 22:07:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RP_MATCHES_RCVD,SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=RuW4=BJ=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1507673240; bh=3jwsJFAs6/2smE2JQzk2R/BgD5W4paAxvhWFg/kUvQc=; h=From:To:Subject:Date:From:Subject; b=A/Fo5tiwSaVYd0bQO2YzazJNVG0OKGuPSnmFeRr7be6TieFP5GlmqOXNSntRzYTlneQ/Iw3CuoXofsrwKXtWqxagvYYGUvkgXYhEtZ6Ip139dOpSA3VEWVB4tTRsF8vhr64b67/eKKFiNHsj9k8j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aBw0r2dUI2oqgUZkSKw NE9vHbFKp8BzZmrH4x_.mLmelDBj1o.Gfo7jRL_q8gkIbMoiZv4zBRj0wm29 jpGr1XZRf04ZUgIx_5siJiNp4hnqT2QBlnVWO7wzWol03UcfEJ.n__VqG_9x YagJnT9qbeW0ris19aTZ58jvqCpw1zD4FItlLwbscxeQ.sFqlPQjTr8YWwRK Q6HPGfcwgPutbzv8q_UxdRxzu0kfCuoyoC079mR4AIgUz1w-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- From: Oliver Kiddle To: Zsh workers Subject: PATCH: handle various systems in ping completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26677.1507673238.1@thecus.kiddle.eu> Date: Wed, 11 Oct 2017 00:07:18 +0200 Message-ID: <26678.1507673238@thecus.kiddle.eu> ping completion was handling just iputils (Linux) and FreeBSD. This now has a big case statement to handle the usual BSDs plus Linux and Solaris along with the ping6 command for systems that have it. Oliver 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 +local variant +local -a args + +_pick_variant -r variant iputils=iputils $OSTYPE -V - _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' +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 -else - - _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' - -fi +_arguments -s -S $args \ + '*:host:_hosts'