zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: _arguments trips on dog
Date: Fri, 30 Dec 2022 20:54:00 -0800	[thread overview]
Message-ID: <CAH+w=7YG2WRTYOL8JzKvS7kS0g1Fda0W64S3Zj68XuadDFeJcg@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3SXUWyzBb0k=Sz0=xFspeC1Nv94xy1Oghr9qV54tWNctg@mail.gmail.com>

On Mon, Dec 26, 2022 at 1:08 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> _arguments:comparguments:327: invalid option definition:
> -w[cols][print first 'cols' characters of each line (default=80)]

Trying to track this down has caused me to realize that

  _call_program ... 2>&1

trips badly on _complete_debug.  The trace output ends up captured
despite efforts within _call_program to fix the redirection.  I would
think the right thing to do is pass a flag to _call_program indicating
that the stderr of the called command is wanted, and let _call_program
do the 2>&1 itself.  Anyway, that's for another thread.

> which is due to this line in dog --help output:
>  -w[cols]               print first 'cols' characters of each line (default=80)

This does *something* but doesn't really get the details right, and
I'm not sure it should be generalized here.

diff --git a/Completion/Base/Utility/_arguments
b/Completion/Base/Utility/_arguments
index 5ff34ff47..c803d1133 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -134,6 +134,12 @@ if (( long )); then
      # maybe needs to be more general
      if [[ $start = (#b)--\[(*)\](*) ]]; then
        tmp+=("--${match[1]}${match[2]}" "--${match[2]}")
+     elif [[ $start = (#b)-(-#*)(\[*\]) ]]; then
+       # variant syntax seen in dog:
+       # -w[cols] print first 'cols' characters of each line (default=80)
+       # means a number follows -w with no space or equals
+       rest="\\-${match[1]}${(b)match[2]} ${rest##[[:space:]]#}"
+       tmp+=("-${match[1]}")
      else
        tmp+=($start)
      fi

Maybe this gives someone else a better hint.


      reply	other threads:[~2022-12-31  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26  9:07 Mikael Magnusson
2022-12-31  4:54 ` Bart Schaefer [this message]

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='CAH+w=7YG2WRTYOL8JzKvS7kS0g1Fda0W64S3Zj68XuadDFeJcg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=mikachu@gmail.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).