From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29437 invoked by alias); 24 Mar 2018 13:59:15 -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: List-Unsubscribe: X-Seq: 42520 Received: (qmail 28408 invoked by uid 1010); 24 Mar 2018 13:59:15 -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.4/5.0):. Processed in 18.358079 secs); 24 Mar 2018 13:59:15 -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.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=kkOk=GO=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=1521899931; bh=VLThuAxkoUbFs+JcsringCUEndqrJWeLeC8ybTRkQpA=; h=From:To:Subject:Date:From:Subject; b=esRTKfMBlFap5o1qDZaT3vIOd+yBLbMJn0ek7TBQ+fglzZ2dI6bcwylIHZvRl2HZWuqMplWUgmdevYpb+bD5o5tsCQpHv7PQwtbL+/vcJ4jnkYoWcy1xTgo8EzKpQtGUfw/++SuJeSsLcMMKTMzlD5508wo+KUWlGu2NuihxUpagniJ035092RRXHiUr+LrWCcgB9FC7MAtCuKVJTeb5ftuz/uTG+mPIZXcSSdznIOc4vL8vShMeNIviDBvBsGkkcn2QLIMwwbjcapUVnZH7haMVsgJXBNMaSUT/VXCoFh7bJ5FwvzrJWlNBPppcRb6DMxLSL2f60mgGrnTnOmc9XQ== X-YMail-OSG: aIb1FJkVM1kUyK9c1huBqRO827a04c9j3PUFwl0dB_JsttsbDnj2hqIqZydUWaF ZefA6usejur2lHKc3hK7EEyobzX0MbM7GPPGI1OVllnofUlcC1x4X2iCZJbVPXfNoTXL9YmsNmev 4tVFtVf9WTSUtzSJcKkSG6NKUM_rkTuunyzFomeT_XiPsC_mupt5D2ciuQLVhA5z6X0TDE1CwHxY voGRB03IUm8e3CB5cbeuDYnEDzGh3Nd0grHNJjVzuAh4fRJ9kH8bZVNW4rrdZnx8Jfm19.kyr.gC KkzC3x1EHiFJrBNwYAJlVRDPYZ0qUvEHaZNlxrew5zgxRJptrRFK3q_ycY7Eh4wJigQYBLjeLMTN JmcODeuirFNgrrl_HpDy1RYOZ.kXvTZtPlKH69lqt5nzfP0X7JGVZhqYbSJ_kXhAQ7mEJicNDa4A vujq5RRvAxGwqg3bzaLzI4KVMjCJtaplEMjj20XmV72WL6MeYC14pVneADFELJ2bqdq9TB7CYd2B zydz8XV8Qrw-- From: Oliver Kiddle To: Zsh workers Subject: PATCH: option cache in netcat completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7737.1521899133.1@thecus> Date: Sat, 24 Mar 2018 14:45:33 +0100 Message-ID: <7738.1521899133@thecus> This is a fairly minor tweak to netcat completion for something that confused me. If you have netcat installed as nc but not as netcat and try: netcat - It creates an empty array for the cache. Thereafter, option completion won't work after nc either. This change uses $#array instead of $+array but I've also renamed the variable with a _cache prefix to be more in line with other functions that do caching. The options could really do with filling out but it would have to be a mess to handle GNU netcat, traditional netcat, each of the BSDs and openbsd netcat installed on Linux. And socat is better anyway. Oliver diff --git a/Completion/Unix/Command/_netcat b/Completion/Unix/Command/_netcat index 4e4006b30..250d4c85d 100644 --- a/Completion/Unix/Command/_netcat +++ b/Completion/Unix/Command/_netcat @@ -6,11 +6,12 @@ if [[ $service = nc ]] && ! _pick_variant netcat=connect nedit -h; then return fi -if (( ! $+_nc_args )); then +if (( ! $#_cache_nc_args )); then + typeset -ga _cache_nc_args local help="$(_call_program options $words[1] -h < /dev/null 2>&1)" local -A optionmap optionmap=( - '*-e prog*' '-e+[program to exec after connect]:prog:_command_names -e' + '*-e prog*' '-e+[program to exec after connect]:program:_command_names -e' '*-g gateway*' '-g+[source-routing hop point]:gateway:_hosts' '*-G num*' '-G[source-routing pointer: 4, 8, 12]' '*-i secs*' '-i+[delay interval for lines sent or ports scanned]:delay (secs)' @@ -28,10 +29,10 @@ if (( ! $+_nc_args )); then '*-x*' '-x' '*-b*' '-b[allow broadcasts]' ) - _nc_args=($optionmap[(K)"$help"]) + _cache_nc_args=( $optionmap[(K)"$help"] ) fi _arguments -s \ - "$_nc_args[@]" \ + "$_cache_nc_args[@]" \ ':host:_hosts' \ ':port:_ports'