3

I've been using kill $(pidof ) to terminate programs for a while, and since last night, every time I try to use tab completion inside the $() it throws an error,

bash: unexpected EOF while looking for matching `)'
bash: syntax error: unexpected end of file

Tab-completion works fine outside of command substitution.

I guess my question is where are the configuration files for tab-completion located on an Ubuntu system? If anyone has had this specific problem, or can see plainly what I cannot, how to fix this, and/or why this would occur? (I always want to know why.) and if not that, even where and how I should begin my investigation into this problem, would be greatly appreciated.

UPDATE

tab completion following $(pidof is no longer throwing an error, but is now not working at all. I've never really messed with any bash internals before, but am not afraid to get my hands dirty. Any guidance greatly appreciated.

  • Double-check for typos. What is PROCESS_NAME set to when you run the command? – jw013 Aug 27 '14 at 2:28
  • Sorry I edited my example to hopefully be more clear. The problem is that when I type in $(pidof and a few characters of the target processes' name, then try to tab complete it throws an error. And what's worse is that now it's not doing this, but tab-completion after pidof is no longer working at all. – blanket_cat Aug 27 '14 at 2:35
  • 1
    $() is called command substitution. – jw013 Aug 27 '14 at 2:42
  • 1
    There's typically a package, such as bash-completion, which includes the completion data files. The command complete makes use of these and is a built-in command to Bash. BTW it sounds like something was introduced in your .bashrc file or .bash_profile that's causing your environment to be "broken". – slm Aug 27 '14 at 2:48
  • 1
    help complete. As I stated it's a built-in command to Bash, so it would be covered by Bash's man page. – slm Aug 27 '14 at 2:55
2

I guess my question is where are the configuration files for tab-completion located on an Ubuntu system?

In Ubuntu, the bash-completion library lives in /usr/share/bash-completion/bash_completion.

When you start a shell, this library can get sourced in a number of ways, e.g.,

  • ~/.bashrc -> /etc/bash_completion -> /usr/share/bash-completion/bash_completion

  • /etc/profile -> /etc/profile.d/bash_completion.sh -> /usr/share/bash-completion/bash_completion

If anyone has had this specific problem, or can see plainly what I cannot, how to fix this, and/or why this would occur? (I always want to know why.)

I recently answered a related question over at AskUbuntu (and found your question in the process), so look there for details, but in a nutshell, this is a known bug.

To fix it, you can either:

  1. Replace

    [[ ${!2} == \$* ]] && eval $2=${!2}
    

    with

    [[ ${!2} == \$\'* ]] && eval $2=${!2}
    

    in the function _quote_readline_by_ref in the file /usr/share/bash-completion/bash_completion (not recommended); or

  2. Check out the newest Git version of the bash-completion library and use that - the bug seems to be fixed in this version.

You won't get tab completion inside command substitution working again with either of these solutions, but at least, you won't see that error message any longer.

To actually get tab completion inside command substitution working, you will either have to revert to an earlier Bash version (where I hear it was working), or wait for the library to truly fix that issue with Bash 4.3.

  • Thanks I ended up switching to another Linux dist. The whole, "but in a nutshell, this is a known bug." has come up a lot for me with Ubuntu over the last year. – blanket_cat Jan 24 '15 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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