bug-bash
[Top][All Lists]
Advanced

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

Re: [PATCH] use real compspec hash key for compopt output


From: Chet Ramey
Subject: Re: [PATCH] use real compspec hash key for compopt output
Date: Thu, 3 Aug 2023 11:46:07 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 7/28/23 2:52 PM, Grisha Levit wrote:
The output of `compopt' in a running completion function is a command where
the last word is usually the command for which the compspec was defined.

However, if the current compspec was found by using the basename of the
command word, or by invoking default completion, the output will use the
typed command word, rather than a command for which a compspec has been
defined.

$ f() { echo; compopt; }
$ complete -r
$ complete -F f f

$ f ^I
compopt +o [...] f

$ /bin/f ^I
compopt +o [...] /bin/f

In fact, the word printed at the end is the same string that is passed to
the completion function as $1.  I think it would be useful if the compopt
output instead used the actual command for the currently running compspec.
For example, this would allow a completion function to retrieve its
compspec by running `complete -p' with the last word of the `compopt'
output.

Thanks, this seems like a useful change.

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




reply via email to

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