Was working on completions for something else, and thought of this when I saw completions/make checking if COMPREPLY has only a single entry. If it does, that means completion will replace the user's word, rather than show possible completions. In that case, run compopt -o nospace.
And maybe also make sure your possible completions for directories end with /, to trick the shell into appending that. (Sort that out in the subshell that's cded there, so it can tell.) _get_comp_words_by_ref is in /usr/share/bash-completion/bash_completion. You might as well use any of those building blocks. But mostly they're overkill solutions for the problem of noticing when there's a > or < redirect, and completing on filenames for it, and then adjusting the rest of the line like it hadn't happened, I think. AFAICT, that's all you miss out on with local cur="${COMP_WORDS[$COMP_CWORD]}" vs. _get_comp_words_by_ref cur prev If you want more help with this, you should prob. post on stackoverflow about how to complete filenames relative to something other than the current directory. This Ubuntu bug probably isn't the most visible place for anyone to notice and tip you off to a good idea. Since I'm pretty much at the limit of my knowledge of obscure tips and tricks for making something like this not take a lot of code and debugging time. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1394920 Title: complete -o filename can't be used with filenames relative to another directory to handle space vs. trailing / To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/1394920/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs