Tab Completion Broken on SCP with OpenSSH 1:6.2p2-6ubuntu0.1

0

Here is my scenario:

I want to transfer ~/foo.txt to a server aoneill@bar.

I start typing in my command line:

aoneill@aoneill-Laptop:~$ scp fo

At this point I hit <tab> to complete the file name, and my terminal just freezes up. It won't change based on any keystroke, and the cursor is just stuck right next to the fo, unless I <ctrl-C> out.

I am running Ubuntu 13.10, and I do include . /etc/bash_completion in my .bashrc.

This is the only program I really encounter this issue with, and it doesnt seem to be a common problem.

Thanks for the help!

AlexO'Neill

Posted 2014-02-11T19:13:16.443

Reputation: 103

I think we need more info to figure this out. Does this happen with every file and every folder? It only happens with scp? Do you have any customizations in ~/.bashrc? What configuration do you have to look up hostnames, is it DNS? – Kevin Panko – 2014-02-11T19:59:07.753

Answers

0

At this point I hit tab to complete the file name, …

… and the computer, entirely failing to read your mind, did what it actually does when tab is hit at that point, which is try to complete a hostname, possibly consulting all sorts of things from the output of avahi-browse to the output of ruptime. This process can take some time.

(The brave can go and look at the _known_hosts_real function in /usr/share/bash-completion/bash-completion.)

To have completion of a filename at that point, the word that you have typed must either contain a slash (/) character or begin with a dot (.) or a tilde (~) character.

(The brave can similarly see why that is from the _scp function in /usr/share/bash-completion/completions/scp.)

JdeBP

Posted 2014-02-11T19:13:16.443

Reputation: 23 855

Perfect! Thank you. I'll keep that in mind when I use ssh/scp in the future! – AlexO'Neill – 2014-02-14T16:48:01.587

0

I ran into this with Ubuntu 14.04. Using set -x shows that the autocomplete was hanging on ruptime. When I tried to run ruptime myself I found that it wasn't installed. After installing the rwho package the hang was fixed.

sudo apt-get install rwho

COMPREPLY+=($( compgen -W         "$( ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }' )"         -- "$cur" ))
+++ ruptime
+++ awk '!/^ruptime:/ { print $1 }'

The COMPREPLY line calls ruptime without checked to see if it exists. And since I have 'COMMAND_NOT_FOUND_INSTALL_PROMPT=1' enabled the command tries to ask me if I want to install it but the pipe captures the output and hangs.

So the bug may be that COMMAND_NOT_FOUND_INSTALL_PROMPT doesn't check if its being used in a pipe. Or that COMPREPLY doesn't check if the command is installed first.

Posted bug with command-not-found group. https://bugs.launchpad.net/command-not-found/+bug/1534175

jjcf89

Posted 2014-02-11T19:13:16.443

Reputation: 111