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
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/692554

Title:
  Autocomplete fails on some filenames

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/692554/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to