Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh -<TAB> dose not use menu completion
I put the following line (/dev/ttys003 is a tty on which I monitor)
echo '<'$argv'>' >/dev/ttys003
at line 292 of _arguments. When "_arguments -S -s --" is called,
the initial part of the output to /dev/ttys003 is
<-S> <-s> <--help[show this message, then exit]> ...
while the output from "_arugments -S -s -- '*:'" looks like
<-S> <-s> <--help[show this message, then exit]:> ... <:> ...
i.e., a ':' is added to the end of each element of $argv. I believe
this is not a problem, but there is an element which consists of
a single : alone. I guess this ':' is later interpreted as the
argument-1.
I put a few more echo into _arguments to see where this <:> comes
from, and found that the problem is at line 29 of _arguments:
typeset -U lopts
This initialize lopts as a scalar (empty string), not as an empty
array. When lopts is later converted to an array by
lopts+=( new_element )
the original scalar value (empty string) remains as the 1st element.
For example,
$ typeset -U u
$ u+=( one )
$ echo '<'$u'>'
<> <one>
If '*:' is passed to "_arguments --" this empty element becomes ':'
in $argv somewhere.
Replacing -U by -Ua seems to fix the problem (see the patch below),
but:
2015/02/03 02:15, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> The special case of `*:' means both
> MESSAGE and ACTION are empty, which has the effect of causing
> options having no description in the help output to be ordered in
> listings ahead of options that have a description.
I can't reproduce this behavior.
If the sort style is on (default?) then the options with description
are always listed first, while if the sort style is off then the options
without description are listed first, irrespective of whether '*:' is
passed to "_argument --" or not (by modifying the line 27 of _sh).
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index d70c442..1f35e8d 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -26,7 +26,7 @@ if (( long )); then
if (( ! ${(P)+name} )); then
local iopts sopts pattern tmpo dir cur cache
- typeset -U lopts
+ typeset -Ua lopts
cache=()
Messages sorted by:
Reverse Date,
Date,
Thread,
Author