completion of inserted option after command throws bash error

Bug #692562 reported by Erik Gregg
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
bash-completion (Debian)
Fix Released
Unknown
bash-completion (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: bash-completion

This is hard to actually capture since apparently a carriage return is output and overwrites the rest of the line..

ssh -i bash: $index: substring expression < 0

Basically, to reproduce, try this:

1. type 'ssh someuser@somehost'
2. move cursor back between ssh and someuser
3. type '-i ' and hit TAB
4. Error happens.

NOTE: You must follow the instructions exactly. If you do 'ssh -i' and then hit TAB, it works.

My system info:

Description: Ubuntu 10.10
Release: 10.10
  Installed: 1:1.2-2ubuntu1
  Candidate: 1:1.2-2ubuntu1
  Version table:
 *** 1:1.2-2ubuntu1 0
        500 http://www.club.cc.cmu.edu/pub/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status

Thanks!

Erik Gregg (ralree)
tags: added: ssh
Revision history for this message
Javier Moreno (elpasmo) wrote :

I tried to follow your steps exactly but I couldn't reproduce the error:
Ubuntu 10.10 2.6.35-23.41 i686

Can you provide a screenshot of the error?

Changed in bash-completion (Ubuntu):
status: New → Incomplete
Revision history for this message
Erik Gregg (ralree) wrote :
Revision history for this message
Erik Gregg (ralree) wrote :
Revision history for this message
Mark Munkacsy (mark-munkacsy) wrote :

I can also reproduce this, but the key sequence must be followed exactly. I'm running bash 4.1.5(1)-release on Ubuntu 10.10 maverick (Ubuntu 2.6.35-23.41-generic-pae 2.6.35.7). To recreate, I typed the following:
ssh someuser@somehost
Then, before typing <enter>, I used the left arrow key to position the cursor on the space after ssh. I then typed <space><dash><i><space><tab>
This generates an error message which has ranged from "bash: $index: substring expression < 0" to "cword=2er@somehost
words[0]=${!ref}${COMP_WORDS[i]}
words[1]=${!ref}${COMP_WORDS[i]}
words[2]=${!ref}${COMP_WORDS[i]}
cword=2
bash: $index: substring expression < 0". (The error message isn't always the same.)

Revision history for this message
Javier Moreno (elpasmo) wrote :

Mark, your computer is a 64 bits also?

Changed in bash-completion (Ubuntu):
status: Incomplete → New
Revision history for this message
Mark Munkacsy (mark-munkacsy) wrote :

Yes, this is an AMD64, multi-core architecture.

Revision history for this message
Javier Moreno (elpasmo) wrote :

It seems to be a regression. I confirm it in Maverick but I couldn't reproduce it in Lucid.

Confirmed in Maveric 10.10 x86_64 2.6.35-24.42, bash-completion 1:1.2-2ubuntu1
Works fine in Lucid 10.04 x86_64 2.6.32-27.49, bash-completion 1:1.1-3ubuntu2

I'll try to test it in Natty tomorrow

Changed in bash-completion (Ubuntu):
status: New → Confirmed
tags: added: regression-release
tags: added: amd64
tags: added: maverick
Revision history for this message
Javier Moreno (elpasmo) wrote :

I confirm it in Natty.

tags: added: natty
Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

oh fun one, this isn't ssh specific, I can trigger it with ls and it doesn't need -i - e.g.

ls fribble

left cursor back to just after the s then type <space>-g<space><tab>

Dave

summary: - ssh -i completion throws bash error
+ completion of inserted option after command throws bash error
Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

Edited the title.

The actual error originates from __get_cword_at_cursor_by_ref in /etc/bash_completion in the code at:

    if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
        # We messed up. At least return the whole word so things keep working
        cur2=${words[cword]}
    else
        cur2=${cur:0:$index}
    fi

The $index in that last expression is -1 in this case.

But then the bash gets a bit deep for me to dig further.

Dave

Revision history for this message
Javier Moreno (elpasmo) wrote :

Adding a bugwatch is failing right now. Here the Upstream link: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=608046

Changed in bash-completion (Debian):
status: Unknown → Confirmed
Changed in bash-completion (Debian):
status: Confirmed → Fix Released
Changed in bash-completion (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.