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    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to