Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _arguments trips on dog



On Mon, Dec 26, 2022 at 1:08 AM Mikael Magnusson <mikachu@xxxxxxxxx> 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.




Messages sorted by: Reverse Date, Date, Thread, Author