#compdef socket # Parameter used: # # socket_hosts_ports # The array that contains paris `host:port'. local state line expl typeset -A options _arguments -s \ -{b,c,f,q,r,v,w} \ -{s,l} \ '-p:command:->command' \ ':arg1:->arg1' \ ':arg2:->arg2' case "$state" in command) compset -q _normal ;; arg1) if (( $+options[-s] )); then _message 'port to listen' else _description expl 'host' _combination socket_hosts_ports hosts "$expl[@]" fi ;; arg2) if (( ! $+options[-s] )); then _description expl 'port to connect' _combination socket_hosts_ports hosts="${line[2]:q}" ports "$expl[@]" fi ;; esac