Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-type;
        bh=1Vxoko4aitn82BmrLwDUoCnojtGkkthqhHziXCemjMk=;
        b=FnCyKzAGiKjUWiVVGoLzRYBvP6KmK3KbpMeyPbAaOIP1i6aMCOP5WYLa70P2YMOcsQ
         KRjpjW6pXnFMFh5m2xr32h+Hj/CB0JI5U9BT7SJyxrgdkrtSbVHcIDo6hl2NOPDgBPJv
         vhC4QnDKtAS2akNFLpiIjqHzNoQwnqONQjFm2w1yT7Ics2Kku+FhVpFkZL7+Rs9/pUKU
         yW2YyZDOLaMg8COrw3NebImezN3QjZTNC6/HDfEZgMBuIlQW4pIirHP/O5sWza7iuFx9
         fyOjEjee65GBb64ycvI7mv4xnF0mm8xvUEzXY4KK1LOd6yq/0F80Kdf1SFXu0rbPlcfT
         c8Ag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc:content-type;
        bh=1Vxoko4aitn82BmrLwDUoCnojtGkkthqhHziXCemjMk=;
        b=CRY5mSj36xAxfQH/mFCun8fG6lWiwBPhYyySIfGz2Zzz6ac81pGUp+S931VVEgM687
         H+KUEgVH65SEXTZtfUrCmagIsMoqhxbVxn+5qfs6pd6w1RUrQSWKCFAh9Zmi0SwwxG3p
         Nt4k+7ieRSxT0zphYzVsco1d2Uf1m64dh4tk0OlU+DaHx9Kdrem44rKyClPr1ilDhmC7
         3QWgUV0InrUEi1i39km0WbCKuwkdkEKlv+fXUY0Joo6pEUAl3EWTzY45aTBEK1c35LXF
         6pZHVDrXeqV6nYpqa9W8/NFsOnkOHEInJO8rfpRGzH88xGsBy6UPEyRLm6XXyFDElIdf
         eyUQ==
X-Gm-Message-State: AG10YOStpZ6UYvO1Ib6MZ0cEnGtr4Gv45DJFlD/55QpakQvYbaQrcr3cagIZbErRwxtDZiSL7ybATOpmziJVrA==
X-Received: by 10.25.41.193 with SMTP id p184mr9373545lfp.150.1453834800228;
 Tue, 26 Jan 2016 11:00:00 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <160126102847.ZM18281@torch.brasslantern.com>
References: <CAKc7PVAtu3Mvu2-rhqGiqqWZ34bOkP7mepPOoF-nZAejVUZoiA@mail.gmail.com>
 <160126102847.ZM18281@torch.brasslantern.com>
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 26 Jan 2016 19:59:40 +0100
Message-ID: <CAKc7PVDOgT0MSot6jVFhXdum3myjCCv1vhTiuatwZyYBmQ_iCQ@mail.gmail.com>
Subject: Re: Advanced option parsing across zsh commands
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 37795

On 26 January 2016 at 19:28, Bart Schaefer <schaefer@brasslantern.com> wrote:
> } % set -- a -b something -- -c
> } % typeset -A opts
> } % zparseopts -A opts -DE b: c
> } % echo "${(kv)opts}"
> }
> } % # $1, $2, ... $5 are still the same
>
> You can't stack the options of zparseopts itself, i.e, you can't use -DE,
> you have to use -D -E.

Thanks, this works

> zparseopts also doesn't handle "negated options" in the +X format, only
> those introduced with "-".  There's a fairly convoluted issue with making
> "+" work for the associative array case because of the way zparseopts
> gathers up the arguments of each option before assigning to the array.

This sounded like if there would a workaround for +X. I tried the
following: define option "+", which takes argument. Then replace "+X"
with "-+X" in the command line. However:

% unset opts
% typeset -A opts
% set -- a -b something -+X -- -c
% zparseopts -A opts -D -E b: c +:
% echo "${(k)opts}"

% echo "${(v)opts}"
b+X

Weird, isn't it? With also a regular array:

% unset opts
% unset optsa
% typeset -A opts
% typeset -a optsa
% set -- a -b something -+X -- -c
% zparseopts -a optsa -A opts -D -E b: c +:
% echo ${(k)opts}

% echo ${(v)opts}
b+X
% echo $optsa
b - +X

With only regular array it's the same

Best regards,
Sebastian Gniazdowski

