bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specify completion without name


From: Chet Ramey
Subject: Re: Specify completion without name
Date: Thu, 05 Jan 2012 10:45:42 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 1/5/12 10:21 AM, Peng Yu wrote:
>> Presumably you would also include aliases, shell builtins, and functions
>> in this file.
> 
> Yes. I just want to replace executables in PATH by the result from my
> custom function. I think that aliases, builtins, and functions are all
> in the memory of bash already, so it doesn't take extra time to search
> them from bash. Therefore, the ideal behaviors is that bash still
> search for aliases, builtins and functions, and in addition check the
> results returned by my custom function. Hence, my custom function
> should not return anything about them (this should be expect at least
> by default).

That's inelegent, and it's inconsistent with how programmable completion
works.  A shell function run for programmable completion has complete
control over the possible completions, as modified by options like
-o bashdefault, not replacing only portions of the default completions
to solve some perceived performance problem.

I would envision that such a completion function would assemble its list
of possible completions by using your read-from-a-file mechanism and
augment the list using compgen -a/compgen -b/compgen -A function.  It
would probably also want to handle glob patterns and expand them to
potentially multiple completions, but that gets tricky.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]