From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6501 invoked by alias); 14 Feb 2014 07:55:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18447 Received: (qmail 23019 invoked from network); 14 Feb 2014 07:55:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Z0pZatTxx6hRwQo4GcLLE0WlK/QCPz17Y68ocxyQ67A=; b=uH/9Et4K7SF9sFX9ZmPG4GwKCZFftAN9tf7rn2B5S8c/GKi8aCQrAsbu1kr6N9d0tE XML+98CSwBNjgraqNg21EBfk9ev8f4s0YQetf4IC/rs/1eF2Xa3wPVCTdi3kXGkkoLyN JgHSzK8e7fdBn8olEWJAXcRFaRAIqjPRmd5E4IQGPusQjQuWcr4xosHBoyCeXd1LUOPb dJr2+HxLDv4Mmlk5zA8RKcgVEfLskoBmTVrcwLI4MWBR3jzRk+KrmBlO9wKmKaeRNHwg ZllaccNpLf8GZ764Em3E73wgzhKbQHxlquitYnsD/VyiviLxdTMR/rXHkt3xhMVmNvS8 ZYcw== MIME-Version: 1.0 X-Received: by 10.180.24.134 with SMTP id u6mr246543wif.41.1392364535044; Thu, 13 Feb 2014 23:55:35 -0800 (PST) In-Reply-To: <140213085618.ZM26934@torch.brasslantern.com> References: <140213085618.ZM26934@torch.brasslantern.com> Date: Fri, 14 Feb 2014 08:55:34 +0100 Message-ID: Subject: Re: zparseopts default associative array From: Sebastian Stark To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 Thanks for your very helpful answer. Is there any chance this gets implemented one day or do I have to find a workaround? I am facing changes to some scripts that used -K the wrong way, leading to funny bugs. 2014-02-13 17:56 GMT+01:00 Bart Schaefer : > On Feb 13, 8:17am, Sebastian Stark wrote: > } > } Maybe I misunderstood something, but isn't my example the intended use > } of -K? Or is the condition "when none of the specs for them is used" > } really meant like "if one option is given, all other default values > } are emptied"? How would this make sense? > > Yes, it really does mean that the defaults are kept only if NONE of > the possible options for the array are parsed. Although it applies to > the default arrays, the intended usage is really with the =array form > as in this snippet of Completion/Base/Core/_description: > > gropt=(-J) > xopt=(-X) > nopt=() > zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt > > In this example -V and -J are mutually exclusive. (There seem to be a > number of unnecessary uses of -K in the Completion tree.) Before the > introduction of -K, gropt and xopt would have been unconditionally > erased by having merely been mentioned in the zparsopts arguments. > > Yes, it would probably make sense for associative arrays if -K retained > individual elements for associative arrays, but the implementation does > the equivalent of the whole-array assignment o=(-a foo) for both plain > and associative arrays because there is no useful way to do individual > element assignment in the non-associative case. Unfortunately -K was > an afterthought added with the minimal possible code changes.