bash-completion not working properly with directories with spaces in them when using some commands
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash-completion (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Good evening!
Unfortunately, I need to report an issue with Ununtu 20.04's bash-completion (bash_completion version 2.10). It can't properly expand directories with spaces when there are multiple options when using some commands. Here is an example:
$ mkdir -p "p00p/p00p 1"
$ mkdir -p "p00p/p00p 2"
$ ls -d p00p/p00p\ 1 p00p/p00p\ 2
'p00p/p00p 1' 'p00p/p00p 2'
$ ls p00p/p0<tab><tab>
p00p 1/ p00p 2/
$ ls p00p/p0<tab>1<tab> # <-- works: yields the expanded command: ls p00p/p00p\ 1/
$ wine p00p/p0<tab><tab> # <-- does NOT work: fails to show possible expansions: p00p 1/ p00p 2/
$ wine p00p/p0<tab>1<tab> # <-- does NOT work: fails to expand to: wine p00p/p00p\ 1/
I temporarily fixed it by patching the portion of bash_completion which invokes plusdirs with the version from my raspberry pi OS (bash_completion version 2.8). Here's the patch that fixes it:
--- /usr/share/
+++ /home/xxx/
@@ -563,37 +559,28 @@
_tilde "$cur" || return
local -a toks
- local reset
+ local x reset
- if [[ "$1" == -d ]]; then
toks=( $(compgen -d -- "$cur") )
- IFS=' '; $reset; IFS=$'\n'
- else
+ eval $reset
+
+ if [[ "$1" != -d ]]; then
local quoted
# Munge xspec to contain uppercase version too
# http://
- local xspec=$
-
- # Use plusdirs to get dir completions if we have a xspec; if we don't,
- # there's no need, dirs come along with other completions. Don't use
- # plusdirs quite yet if fallback is in use though, in order to not ruin
- # the fallback condition with the "plus" dirs.
- local opts=( -f -X "$xspec" )
- [[ $xspec ]] && plusdirs=(-o plusdirs)
- [[ ${COMP_
-
+ local xspec=$
- toks+=( $(compgen "${opts[@]}" -- $quoted) )
- IFS=' '; $reset; IFS=$'\n'
+ toks+=( $( compgen -f -X "$xspec" -- $quoted ) )
+ eval $reset
# Try without filter if it failed to produce anything and configured to
[[ -n ${COMP_
- toks+=( $(compgen -f "${plusdirs[@]}" -- $quoted) )
- IFS=' '; $reset; IFS=$'\n'
+ toks+=( $( compgen -f -- $quoted ) )
+ eval $reset
}
fi
<EOF>
Unfortunately, to apply the patch with patch -p0, I had to type in the name of the file to patch because the patch I saved was only a subset of the patch produced by "diff -u -w" and my diff-fu isn't good enough to know how to fix it. But, providing the name of the file to be patched when prompted (/usr/share/
Thus, this appears to be a regression of sorts but my bash programming skills aren't good enough to fix it myself while ensuring that any functionality provided by the portions that I replaced isn't lost.
Thank you!
Very sincerely,
Jason A. Pfeil
ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: bash-completion 1:2.10-1ubuntu1 [modified: usr/share/
ProcVersionSign
Uname: Linux 5.4.0-45-generic x86_64
NonfreeKernelMo
ApportVersion: 2.20.11-0ubuntu27.8
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: ubuntu:GNOME
Date: Fri Sep 4 20:50:10 2020
Dependencies:
EcryptfsInUse: Yes
InstallationDate: Installed on 2020-08-29 (7 days ago)
InstallationMedia: Ubuntu 20.04.1 LTS "Focal Fossa" - Release amd64 (20200731)
PackageArchitec
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: bash-completion
UpgradeStatus: No upgrade log present (probably fresh install)
tags: | added: rls-ff-incoming |
In case the copy and paste of the text of the patch isn't usable, I have attached the file to this bug to make it easier to evaluate.
Thank you!
Very sincerely,
Jason A. Pfeil