1

I'm using Ubuntu 14.04.5 LTS.

The ssh bash completion on any Host of the file ~/.ssh/config does not work :

$ ssh b2sed: -e expression #1, char 97: invalid reference \2 on `s' command's RHS 

The package for the ssh completion, is already installed :

$ dpkg -S /usr/share/bash-completion/completions/ssh bash-completion: /usr/share/bash-completion/completions/ssh 
3
  • @Kusalananda Thanks, I have just seen that sed is aliased to \sed -E on my system. I'm searching where in the bash-completions scripts, this particular sed call is done ... Commented Feb 23, 2019 at 17:48
  • @Kusalananda I found a way but I think it is not recommanded, please see my EDIT1 Commented Feb 23, 2019 at 18:02
  • 2
    You should submit a bug report so that it's fixed in the bash-completion package. Your fix is correct and what the function should have used from the start. Commented Feb 23, 2019 at 18:35

1 Answer 1

1

I found that on my system, sed is aliased to sed -E

So instead of removing this alias which I use quite a lot actually, I decided to update the _known_hosts_real function in the /usr/share/bash-completion/bash_completion script (which I think is not really recommanded) :

$ type _known_hosts_real | grep -w sed local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" ); 

by replacing sed -ne by command sed -ne, this way :

# append any available aliases from config files if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then local hosts=$( command sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" ) COMPREPLY+=( $( compgen -P "$prefix$user" \ -S "$suffix" -W "$hosts" -- "$cur" ) ) fi 

However, those changes are going to be lost when the bash-completion package gets updated.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.