[Bug 1394920] [NEW] Filename completion not working if current directory does not match with COMPREPLY array
hakon
hakon.hagland at gmail.com
Fri Nov 21 09:20:00 UTC 2014
Public bug reported:
I am trying to ignore certain directory names when using bash
completion. For example to ignore "backup" directories I use
$ cat setup.sh
_compTest() {
local curdir cur words val name
cur="${COMP_WORDS[$COMP_CWORD]}"
baseFolder="."
curdir=$PWD
cd "$baseFolder"
words=( $(compgen -f "$cur") )
COMPREPLY=()
for val in "${words[@]}" ; do
name=$(basename "$val")
if [[ $name == "backup" ]] ; then
continue
fi
COMPREPLY+=( "$val" )
done
cd "$curdir"
}
complete -o filenames -F _compTest aaa
After sourcing this:
$ . setup.sh
I can type
$ aaa <tab><tab>
and it works fine. However if I use another baseFolder, for example
setting
baseFolder="$HOME/base"
in the above script (setup.sh) (where $HOME/base is different from the
current directory) the completion list is no longer what I would expect.
That is:
* slashes are missing at the end of directory names, and
* a space is added after each completed directory name, instead of a slash ("/")
$ lsb_release -rd
Description: Ubuntu 14.04.1 LTS
Release: 14.04
$ apt-cache policy bash-completion
bash-completion:
Installed: 1:2.1-4
Candidate: 1:2.1-4
Version table:
*** 1:2.1-4 0
500 http://no.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages
100 /var/lib/dpkg/status
** Affects: bash-completion (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/1394920
Title:
Filename completion not working if current directory does not match
with COMPREPLY array
Status in “bash-completion” package in Ubuntu:
New
Bug description:
I am trying to ignore certain directory names when using bash
completion. For example to ignore "backup" directories I use
$ cat setup.sh
_compTest() {
local curdir cur words val name
cur="${COMP_WORDS[$COMP_CWORD]}"
baseFolder="."
curdir=$PWD
cd "$baseFolder"
words=( $(compgen -f "$cur") )
COMPREPLY=()
for val in "${words[@]}" ; do
name=$(basename "$val")
if [[ $name == "backup" ]] ; then
continue
fi
COMPREPLY+=( "$val" )
done
cd "$curdir"
}
complete -o filenames -F _compTest aaa
After sourcing this:
$ . setup.sh
I can type
$ aaa <tab><tab>
and it works fine. However if I use another baseFolder, for example
setting
baseFolder="$HOME/base"
in the above script (setup.sh) (where $HOME/base is different from the
current directory) the completion list is no longer what I would
expect. That is:
* slashes are missing at the end of directory names, and
* a space is added after each completed directory name, instead of a slash ("/")
$ lsb_release -rd
Description: Ubuntu 14.04.1 LTS
Release: 14.04
$ apt-cache policy bash-completion
bash-completion:
Installed: 1:2.1-4
Candidate: 1:2.1-4
Version table:
*** 1:2.1-4 0
500 http://no.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages
100 /var/lib/dpkg/status
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1394920/+subscriptions
More information about the foundations-bugs
mailing list