Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Advanced option parsing across zsh commands
- X-seq: zsh-workers 37795
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Advanced option parsing across zsh commands
- Date: Tue, 26 Jan 2016 19:59:40 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- 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==
- In-reply-to: <160126102847.ZM18281@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAtu3Mvu2-rhqGiqqWZ34bOkP7mepPOoF-nZAejVUZoiA@mail.gmail.com> <160126102847.ZM18281@torch.brasslantern.com>
On 26 January 2016 at 19:28, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author