Bug 1782809 - Bash 'direxpand' and 'dirspell' options make completion remove typed character
Summary: Bash 'direxpand' and 'dirspell' options make completion remove typed character
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 35
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-12-12 11:40 UTC by Jonathan Wakely
Modified: 2021-11-01 12:04 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-11-01 12:04:10 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jonathan Wakely 2019-12-12 11:40:33 UTC
Description of problem:

Trying to TAB complete a directory name removes the last typed character instead of completing the name.

Version-Release number of selected component (if applicable):

bash-5.0.11-1.fc31.x86_64
bash-5.0.11-1.fc30.x86_64

How reproducible:

Always

Steps to Reproduce:
1. shopt -s direxpand 
2. mkdir /tmp/xxx /tmp/xxx/a /tmp/xxx/abc
3. type "/tmp/xxx/ab<TAB>"

Actual results:

The last character is removed, leaving "/tmp/xxx/a"

Expected results:

The directory name should be completed as "/tmp/xxx/abc"

Additional info:

This only seems to happen for directories on a tmpfs mount point. I can reproduce it in /tmp and in /dev/shm

It only happens when trying to complete an absolute path, cd ./ab<TAB> works fine.

Comment 1 Ben Cotton 2020-11-03 15:59:04 UTC
This message is a reminder that Fedora 31 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora 31 on 2020-11-24.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
Fedora 'version' of '31'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 31 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Jonathan Wakely 2020-11-03 18:27:42 UTC
The bug is still present in F32's bash-5.0.17-1.fc32.x86_64 but seems to be fixed in F33's bash-5.0.17-2.fc33.ppc64le which is odd.

Comment 3 Kamil Dudka 2020-11-04 09:43:59 UTC
Do you use bash-completion or just bash on its own?

Comment 4 Jonathan Wakely 2020-11-05 13:11:05 UTC
I use bash-completion on the F32 machine, but I still see the same behaviour if I remove the bash-completion package and then login to a new virtual console with ctrl-alt-f2 and run the steps above. And on the F33 machine I don't see it, even if I install bash-completion and login again.

Comment 5 Jonathan Wakely 2020-11-05 13:14:05 UTC
Ah, I can reproduce it on F33, but I didn't realise that you also need dirspell set.

Steps to Reproduce:
1. shopt -s direxpand dirspell
2. mkdir /tmp/xxx /tmp/xxx/a /tmp/xxx/abc
3. type "/tmp/xxx/ab<TAB>"

This should reproduce it on F32 and F33, without bash-completion installed.

Comment 6 Kamil Dudka 2020-11-06 08:19:53 UTC
Thank you for clarifying it!

I am able to reproduce it with bash-5.0.17-2.fc33 using `env -i /bin/bash --norc` on f33 (running kernel-5.8.16-300.fc33) but not on f34 (running kernel-5.10.0-0.rc1.20201028gited8780e3f2ec.57.fc34).  The only important difference between those machine seems to be the order in which getdents64 returns the contents of /tmp/xxx.


f33:
getdents64(3, [
    {d_ino=524775, d_off=1380185562790879955, d_reclen=24, d_type=DT_DIR, d_name="."},
    {d_ino=524778, d_off=2766247172007987392, d_reclen=24, d_type=DT_DIR, d_name="a"},
    {d_ino=524779, d_off=4124671994579598501, d_reclen=24, d_type=DT_DIR, d_name="abc"},
    {d_ino=524290, d_off=9223372036854775807, d_reclen=24, d_type=DT_DIR, d_name=".."}
], 32768) = 96


f34:
getdents64(3, [
    {d_ino=23258, d_off=1, d_reclen=24, d_type=DT_DIR, d_name="."},
    {d_ino=21106, d_off=2, d_reclen=24, d_type=DT_DIR, d_name=".."},
    {d_ino=23260, d_off=3, d_reclen=24, d_type=DT_DIR, d_name="abc"},
    {d_ino=23259, d_off=4, d_reclen=24, d_type=DT_DIR, d_name="a"}
], 32768) = 96


My guess is that bash expects the items "." and ".." to always come first.

Comment 7 Kamil Dudka 2020-11-06 08:37:40 UTC
Please ignore the previous comment.  My f34 VM did not have /tmp mounted as tmpfs, which prevented the bug from triggering.  My bad.

Comment 8 Jonathan Wakely 2021-08-06 12:03:58 UTC
Still reproducible with f34 and rawhide

bash-5.1.8-2.fc35.x86_64

Comment 9 Jonathan Wakely 2021-08-06 12:42:15 UTC
For paths /tmp/xxx/{a,abcdefghi} completion works correctly for /tmp/xxx/abc<TAB>, it only goes wrong for /tmp/xxx/ab<TAB>

So it's not just that the a and abc are equal distances from ab, because it happily picks abcdefghi despite that being further from abc than a is.

http://git.savannah.gnu.org/cgit/bash.git/tree/lib/sh/spell.c?id=ce23728687ce9e584333367075c9deef413553fa#n103 might be relevant (or not).

Comment 10 Ben Cotton 2021-08-10 12:46:55 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle.
Changing version to 35.

Comment 11 Siteshwar Vashisht 2021-11-01 12:04:10 UTC
It was fixed in upstream by this commit[1], specifically by this change[2]. This should be fixed in next rebase.

[1] http://git.savannah.gnu.org/cgit/bash.git/commit/?id=ea32b611f76a549cb961885e8b3e64467436d215
[2] http://git.savannah.gnu.org/cgit/bash.git/diff/bashline.c?id=ea32b611f76a549cb961885e8b3e64467436d215


Note You need to log in before you can comment on or make changes to this bug.