[Bug 692554] Re: Autocomplete fails on some filenames
Peter Cordes
peter at cordes.ca
Sat Nov 29 05:45:05 UTC 2014
Hmm, well what's crossing it up is the embedded newline in the filename.
_filedir does
local IFS=$'\n'
...
x=$( compgen -f -X "$xspec" -- "$quoted" ) &&
while read -r tmp; do
toks+=( "$tmp" )
done <<< "$x"
...
if [[ ${#toks[@]} -ne 0 ]]; then
# 2>/dev/null for direct invocation, e.g. in the _filedir unit test
compopt -o filenames 2>/dev/null
COMPREPLY+=( "${toks[@]}" )
fi
and apparently it's the COMPREPLY+= line where the error pops up. At
least, that's the last line that shows in the set -xv output, so maybe
the caller, is where it's getting used in a way that lets the shell get
at the backquote.
If you leave out the \n in the filename, it works fine. If you leave
out the `, but keep the newline, you get weirdness. (completes the
filename, but thinks it's ambiguous, and lists all files in the
directory.) Probably because you get an empty element in your COMPREPLY
array. No idea how the backquote comes into it.
So I guess if you have embedded newlines in your filenames, best to
just use alt-/ to complete them. Working with embedded newlines sucks,
in shell programming.
--
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/692554
Title:
Autocomplete fails on some filenames
Status in bash-completion package in Ubuntu:
New
Bug description:
Binary package hint: bash-completion
After creating a directory or file with the standard escape sequences
available in the Bash $'' string construct, filename autocompletion
fails. For example:
$ mkdir -- $'--$`\! *@ \a\b\e\E\f\r\t\v\\\"\' \n'
$ rm -- \-\-
[press TAB]
$ rm -- \-\-bash: [: --$`\! *@
: binary operator expected
--\$\`\\\!\ \*@\ ^G^H^[^[^L^M\ ^K\\\"\'\
The good news is, if autocomplete can handle this filename, it should
be able to handle _any_ *nix filename, that is, anything that doesn't
contain a null character or a slash.
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: bash-completion 1:1.1-3ubuntu2
ProcVersionSignature: Ubuntu 2.6.32-26.48-generic 2.6.32.24+drm33.11
Uname: Linux 2.6.32-26-generic i686
Architecture: i386
Date: Mon Dec 20 14:05:33 2010
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release i386 (20100429)
PackageArchitecture: all
ProcEnviron:
LC_PAPER=en_GB.UTF-8
SHELL=/bin/bash
LANG=en_US.utf8
SourcePackage: bash-completion
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/692554/+subscriptions
More information about the foundations-bugs
mailing list