Bug#290748: bash: Python completion fails when running Python as './python'

2005-01-16 Thread Johannes Gijsbers
Package: bash
Version: 3.0-13
Severity: minor
Tags: patch


I'm a Python developer, so I frequently run tests from the source directory I
compiled Python in:

[EMAIL PROTECTED]:trunk$ ./python 

press tab

[EMAIL PROTECTED]:trunk$ ./python bash: COMP_WORDS: bad array subscript

My patch fixes this to do normal Python completion.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.10-2-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages bash depends on:
ii  base-files   3.1.0ubuntu1Debian base system miscellaneous f
ii  libc62.3.2.ds1-20ubuntu1 GNU C Library: Shared libraries an
ii  libncurses5  5.4-4   Shared libraries for terminal hand
ii  passwd   1:4.0.3-30.7ubuntu2 Change and administer password and

-- no debconf information
--- bash_completion 2005-01-16 14:13:48.822092312 +0100
+++ /home/johannes/bash_completion  2005-01-16 14:03:47.543500552 +0100
@@ -4803,7 +4803,7 @@
_filedir '@(py|pyc|pyo)'
return 0
;;
-   !(*python|-?))
+   !(python|-?))
[[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]]  _filedir
;;
esac


Bug#290748: bash: Python completion fails when running Python as './python' (forwarded from Johannes Gijsbers)

2005-01-16 Thread Ian Macdonald
On Sun 16 Jan 2005 at 14:42:15 +0100, you wrote:

 X-Loop: [EMAIL PROTECTED]
 Reply-To: Johannes Gijsbers [EMAIL PROTECTED], [EMAIL PROTECTED]
 X-Debian-PR-Message: report 290748
 X-Debian-PR-Package: bash
 X-Debian-PR-Keywords: patch
 X-Mailer: reportbug 3.5ubuntu2
 Delivered-To: [EMAIL PROTECTED]
 X-Virus-Scanned: by amavisd-new at cs.tu-berlin.de (including spamassassin)
 X-Spam-Status: No, hits=0 tagged_above=0 required=3 tests=
 X-Spam-Level: 
 Resent-From: Johannes Gijsbers [EMAIL PROTECTED]
 Resent-To: debian-bugs-dist@lists.debian.org
 Resent-Cc: Matthias Klose [EMAIL PROTECTED]
 Resent-Date: Sun, 16 Jan 2005 13:33:06 UTC
 Resent-Message-ID: [EMAIL PROTECTED]
 Resent-Sender: Debian BTS [EMAIL PROTECTED]
 From: Johannes Gijsbers [EMAIL PROTECTED]
 To: Debian Bug Tracking System [EMAIL PROTECTED]
 Subject: Bug#290748: bash: Python completion fails when running Python as 
 './python'
 Date: Sun, 16 Jan 2005 14:25:20 +0100
 
 Package: bash
 Version: 3.0-13
 Severity: minor
 Tags: patch
 
 
 I'm a Python developer, so I frequently run tests from the source directory I
 compiled Python in:
 
 [EMAIL PROTECTED]:trunk$ ./python 
 
 press tab
 
 [EMAIL PROTECTED]:trunk$ ./python bash: COMP_WORDS: bad array subscript
 
 My patch fixes this to do normal Python completion.
 
 -- System Information:
 Debian Release: 3.1
 Architecture: i386 (i686)
 Kernel: Linux 2.6.10-2-686
 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
 
 Versions of packages bash depends on:
 ii  base-files   3.1.0ubuntu1Debian base system miscellaneous 
 f
 ii  libc62.3.2.ds1-20ubuntu1 GNU C Library: Shared libraries 
 an
 ii  libncurses5  5.4-4   Shared libraries for terminal 
 hand
 ii  passwd   1:4.0.3-30.7ubuntu2 Change and administer password 
 and
 
 -- no debconf information

 --- bash_completion   2005-01-16 14:13:48.822092312 +0100
 +++ /home/johannes/bash_completion2005-01-16 14:03:47.543500552 +0100
 @@ -4803,7 +4803,7 @@
   _filedir '@(py|pyc|pyo)'
   return 0
   ;;
 - !(*python|-?))
 + !(python|-?))
   [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]]  _filedir
   ;;
   esac

This problem is not in the upstream release. 'cvs annotate' says:

1.435(ianmacd  10-Oct-02):  !(python|-?))

This line hasn't changed since October 2002.

Ian
-- 
Ian Macdonald   | History teaches us that men and nations
System Administrator| behave wisely once they have exhausted all 
[EMAIL PROTECTED] | other alternatives.   -- Abba Eban 
http://www.caliban.org  | 
| 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#290748: bash: Python completion fails when running Python as './python' (forwarded from Johannes Gijsbers)

2005-01-16 Thread Ian Macdonald
On Sun 16 Jan 2005 at 20:04:36 +0100, you wrote:

 On Sun, Jan 16, 2005 at 10:47:22AM -0800, Ian Macdonald wrote:
  This problem is not in the upstream release. 'cvs annotate' says:
  
  1.435(ianmacd  10-Oct-02):  !(python|-?))
  
  This line hasn't changed since October 2002.
  
  Ian
 
 Uhm, sorry, I didn't pay enough attention there. The patch should go
 the other way. Applying it with 'patch -R' should fix the problem.

Ah, now I get it.

I've fixed this another way, which I think is a little cleaner:

At the top of the function:

  prev=${COMP_WORDS[COMP_CWORD-1]}

becomes:

  prev=${COMP_WORDS[COMP_CWORD-1]##*/}

to strip any leading path component.

Ian
-- 
Ian Macdonald   | If it's worth doing, it's worth doing for
System Administrator| money. 
[EMAIL PROTECTED] | 
http://www.caliban.org  | 
| 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]