Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
    
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 Feb 11 '14 at 19:59
up vote 0 down vote accepted

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.)

share|improve this answer
    
Perfect! Thank you. I'll keep that in mind when I use ssh/scp in the future! – AlexO'Neill Feb 14 '14 at 16:48

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.