zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Advanced option parsing across zsh commands
Date: Tue, 26 Jan 2016 19:59:40 +0100	[thread overview]
Message-ID: <CAKc7PVDOgT0MSot6jVFhXdum3myjCCv1vhTiuatwZyYBmQ_iCQ@mail.gmail.com> (raw)
In-Reply-To: <160126102847.ZM18281@torch.brasslantern.com>

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


  reply	other threads:[~2016-01-26 19:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26  9:20 Sebastian Gniazdowski
2016-01-26 18:28 ` Bart Schaefer
2016-01-26 18:59   ` Sebastian Gniazdowski [this message]
2016-01-26 19:09     ` Sebastian Gniazdowski
2016-01-27  7:07       ` Bart Schaefer
2016-01-27  6:56     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVDOgT0MSot6jVFhXdum3myjCCv1vhTiuatwZyYBmQ_iCQ@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).