Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 746881

Summary: app-shells/bash-completion-2.11 gives wrong results when ~ is part of a file/path argument (Regression)
Product: Gentoo Linux Reporter: Michael Moon <triffid.hunter>
Component: Current packagesAssignee: Gentoo Shell Tools project <shell-tools>
Status: UNCONFIRMED ---    
Severity: normal CC: jstein, sam, shell-tools
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge --info

Description Michael Moon 2020-10-06 07:16:26 UTC
Created attachment 664039 [details]
emerge --info

Bash completion gives wrong results when ~ is part of a file argument :-

triffid@dorellan ~ $ cd test
triffid@dorellan ~/test $ ls
fix-pics.sh  imgur-UI22gpD.png  int1  int2  int3  int4  int5  int.c  jp2.png  jp2.txt  OTeWfXXl.jpeg  rds-temp  strftime  strftime.c  temp  test1.sh  test.c  test.cpp  test.ext4  tft-test
triffid@dorellan ~/test $ okular ~/Pdf/LM7
imgur-UI22gpD.png  jp2.png            OTeWfXXl.jpeg   # incorrect completions
triffid@dorellan ~/test $ echo okular ~/Pdf/LM7
lm7171.pdf  LM741.pdf   LM7805.pdf                    # correct completion due to prepending echo that defeats bash completion

This doesn't only affect okular, it seems to affect all completions that specify a file argument:

triffid@dorellan ~/test $ kate ~/Pdf/LM7
fix-pics.sh        int1               int3               int5               jp2.png            rds-temp           strftime.c         test1.sh           test.cpp           tft-test/                          # incorrect completions
imgur-UI22gpD.png  int2               int4               int.c              jp2.txt            strftime           temp               test.c             test.ext4                                             # incorrect completions
triffid@dorellan ~/test $ oowriter ~/Pdf/LM7<tab>
triffid@dorellan ~/test $ oowriter jp2.txt            # incorrect completion

Without ~ in the argument, it seems to work fine:

triffid@dorellan ~/test [130] $ okular
imgur-UI22gpD.png  jp2.png            OTeWfXXl.jpeg      tft-test/   # correct completions
triffid@dorellan ~/test [130] $ okular ./
imgur-UI22gpD.png  jp2.png            OTeWfXXl.jpeg      tft-test/   # correct completions
triffid@dorellan ~/test [130] $ okular /home/triffid/Pdf/LM7
lm7171.pdf  LM741.pdf   LM7805.pdf                                   # correct completions

I can't downgrade since <app-shells/bash-completion-2.11 seems to have been removed:

triffid@dorellan ~ $ l /var/db/repos/gentoo/app-shells/bash-completion/
total 16K
-rw-r--r-- 1 portage portage 3.9K Sep  3 07:09 bash-completion-2.11.ebuild
-rw-r--r-- 1 portage portage 3.9K Jul 27 18:08 bash-completion-9999.ebuild
-rw-r--r-- 1 portage portage 1.6K Sep 20 05:09 Manifest
-rw-r--r-- 1 portage portage 1.5K May  4 18:09 metadata.xml

This erroneous behaviour started after recent updates to bash and bash-completion:

triffid@dorellan ~ $ genlop bash
* app-shells/bash

Sat May  9 18:45:20 2020 >>> app-shells/bash-5.0_p17
Tue Aug 11 14:46:10 2020 >>> app-shells/bash-5.0_p17
Wed Sep 16 18:20:22 2020 >>> app-shells/bash-5.0_p18

triffid@dorellan ~ $ genlop bash-completion
* app-shells/bash-completion

Wed Feb 19 20:08:33 2020 >>> app-shells/bash-completion-2.10
Wed Sep 16 18:21:14 2020 >>> app-shells/bash-completion-2.11

triffid@dorellan ~ $ emerge -pv1O bash bash-completion

These are the packages that would be merged, in order:

[ebuild   R    ] app-shells/bash-5.0_p18::gentoo  USE="-afs -bashlogger -examples -mem-scramble net nls -plugins (readline)" 0 KiB
[ebuild   R    ] app-shells/bash-completion-2.11::gentoo  USE="eselect -test" 0 KiB

I didn't find any similar bugs before reporting this.
Comment 1 Michael Moon 2021-04-26 05:05:16 UTC
This is still happening, and also seems to occur if a filename contains a '#' or a space - even without any directory being specified.

tab-completion in this case will do either one of two things (I haven't determined what triggers one behaviour over the other) - it'll either simply double all the backspaces (ie test\ 1 -> test\\\ 1) or simply remove the trailing specifier (ie test\ 1<tab> -> test)

As noted in my initial comment, this only happens with certain programs for which bash completion rules exist - okular for example is affected, but `mv` and `echo` are not.

This means I frequently have to mis-spell okular, do tab completion, then correct its spelling just so I can open files from a terminal.