On 2/26/26 9:27 PM, Martin D Kealey wrote:
On Fri, 27 Feb 2026 at 04:19, Chet Ramey <[email protected] <mailto:[email protected]>> wrote:It's ambiguous. Both a binary in $PATH and a directory in the current directory can be valid completions, since bash completion (and readline) allows you to build a relative pathname by completing a directory at a time. Because it's ambiguous, the name exists as a directory in the current directory, and you have the `mark-directories' readline variable set, readline appends the slash.I can follow this logic to see why it behaves as it does, except that it it's inconsistent.If you have the full suite of vim installed then Bash shows a list like this:vim vim.basic vim.gtk3 vim.tiny vimdiff vimdot vimplate vimtutorAdd a directory «vim» with «mark-directories» is in effect, and instead you get: vim/ vim.basic vim.gtk3 vim.tiny vimdiff vimdot vimplate vimtutorwhich differs only in the addition of a trailing slash.
Yes. It's ambiguous. When presented with `vim' in the (deduplicated) list of possible completions, readline has to choose which interpretation to take. Since `mark-directories' is set, and this is a directory, it chooses to append the slash.
However, when you only have the vim directory and the vim command, with no other commands machines that prefix, pressing tab shows a single-item listvim which has no slash, regardless of «mark-directories».
Since there is only a single completion, bash can (and does) special-case this and tell readline not to append the slash. It wouldn't be appropriate to do this for more than a single completion, since the appending applies to every possible completion -- either you append, or you don't, to each one.
I contend that «vim» and «vim/» should count as separate completions; this is consistent with:
You'd like readline to annotate the completion list with additional application-specific information, which is nice, but would have to be done via an additional data structure.
I suggest that these inconsistencies (and the original bug report) would be resolved by showing both «vim» and «vim/» in the displayed list; in effect, mark-directories would act to modify each element as it's added to the list of completions, rather acting when when each item is displayed or used to extend the completion.
That's an idea, but it would have to interact with the other annotations
readline does.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
