On 9/27/13 3:57 AM, Jeremy Lin wrote:
> I'm writing a completion where, in some cases, I'd like to use
> COMPREPLY=() to indicate that no more arguments to a command are
> expected, but in other cases, I'd like to offer the default Readline
> behavior for filename completions.
> 
> So, if I have a directory 'foo', I'd like the shell to first complete
> with 'foo/' and then offer to complete files under 'foo'. But if I do
> something like COMPREPLY=($(compgen -f -- "$cur")), then I simply get
> a completion of 'foo' (with a space appended).
> 
> I know I can pass "-o default" to get Readline's default filename
> completion when COMPREPLY is empty, but then that seems to preclude
> using COMPREPLY=() to deny completions.

The `compopt' builtin was intended to add this kind of dynamism to
programmable completion shell functions.  You can install a completion
without -o default and turn it on using compopt when the completion
function is executed.  It appears to be lightly used, so there are
probably some usability improvements to be made there.  For instance, I
think that options, once set using compopt, remain set and need to be
manually disabled.  I'm waiting for some more reports from people using
it before I decide how (or whether) to change it.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to