* _arguments trips on dog
@ 2022-12-26 9:07 Mikael Magnusson
2022-12-31 4:54 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2022-12-26 9:07 UTC (permalink / raw)
To: zsh-workers
I've used compdef _gnu_generic dog (among other commands) for some
time, but I suppose I recently updated dog and now, dog<tab> produces
this error:
_arguments:comparguments:327: invalid option definition:
-w[cols][print first 'cols' characters of each line (default=80)]
which is due to this line in dog --help output:
-w[cols] print first 'cols' characters of each line (default=80)
it looks like _arguments tries to handle things like -foo[=VALUE], but
the expected input here is -w10 or -w , not -w=10. Any takers? I took
a look at the code but I was nonplussed. I suppose it's somewhere
around line 245 or thereabouts. At the least, it would be nice to just
ignore it and still produce the rest of the completion, instead of
dumping errors in the terminal.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: _arguments trips on dog
2022-12-26 9:07 _arguments trips on dog Mikael Magnusson
@ 2022-12-31 4:54 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2022-12-31 4:54 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh-workers
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-31 4:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-26 9:07 _arguments trips on dog Mikael Magnusson
2022-12-31 4:54 ` Bart Schaefer
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).