Comment 6 for bug 692554

Revision history for this message
Peter Cordes (peter-cordes) wrote : Re: Autocomplete fails on some filenames

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.