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

Re: why '_file -/' completes files if there is no directory?



On Aug 9,  1:34am, Jun T. wrote:
}
} Interestingly, 'gcc -I<TAB>' gives nothing, i.e., not completes
} normal files nor gives a warning.
} 'gcc -I./<TAB>' does give a warning, though.

This comes down to some oddness in _describe.  In the first case (no
warnings), "compdescribe -g csl2 _args _tmpm _tmpd" succeeds so a
compadd call is made, _ret=0 is assigned, and _describe returns 0
without reaching the end of the _tags loop.

In the second case, compdescribe fails so _describe falls out of the
_tags loop and returns 1.  You mention that:

} This happens only if the optspec given to _arguments has the form '*-I-'.

In this form, the string "-I" is provided to compadd as a possible
completion (because it is allowed to appear more than once on the
command line).  With the form -I- it is not, because it's allowed only
once; with *-I the code takes an entirely different path because a
separate word is being completed, and _describe is never called.

The result of all this is that with an optspec in the "*-I-" format,
the -I by itself is treated as successful but ambiguous completion,
rather than as a finished option string that needs its argument.  I
think this is probably a bug in comparguments -- it should be able to
tell from the single colon in "*-I-:header file ..." that -I can't
appear a second time without first filling in its mandatory argument
-- but like most of us I'm lost as to whether the problem is with
computil.c:ca_parse_line during "comparguments -i", or whether it's
actually a bug in cd_init or cd_get as part of compdescribe, or ...



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