On 8/22/25 11:27 AM, Aaron Laws wrote:
Bash Version: 5.3 Patch Level: 3 Release Status: releaseDescription: Tab completion with a dollar sign, then a possible variable name, in the presence of ambiguity completes incorrectly.
Not quite, see below. The completion is performed correctly but inappropriately quoted.
The reproduction instructions below illustrate one example, but another can be constructed using the following file names * [$L.a [$L.b Perhaps the original intent was to allow variables inside array indices, and the code is mis-identifying these filenames as array indices?
No, the code is making an assumption that is incorrect in this case.
Repeat-By: 1. touch '[$L]'a '[$L]'b; 2. less <tab> * The completion is less "[$L].
Because bash completion guesses that the user wants the expansion to take place, since there's no filename matching the completion, and double quotes allow that. In this case it guesses wrong, so I'll have to look at that.
3. type "a" 4. press <tab> * The completion is less "[$L]a"
You have a single completion, so readline adds the close quote.
5. press <enter> The following error is shown: []a: No such file or directory
Because the word expansion takes place, there is no variable `L', and so $L expands to nothing.
Fix: I only found commit, c5c97b371044a44b701b6efa35984a3e1956344e, that may be implicated, but I'm not smart enough to make anything out of it.
This doesn't really have anything to do with arrays. It's a quoting problem. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature