Bug 753485 - bash-completion completely hosed
Summary: bash-completion completely hosed
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: bash-completion
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ville Skyttä
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-12 21:46 UTC by Tom Horsley
Modified: 2011-11-13 09:25 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-13 09:25:39 UTC
Type: ---


Attachments (Terms of Use)

Description Tom Horsley 2011-11-12 21:46:01 UTC
Description of problem:

I have a directory on my system named /zooty/

I'm sitting in a terminal and type

cd /zoo

Then hit TAB.

I see this nonsense:

zooty> cd /zoobash: cd: cd: No such file or directory
/home/tom/

Version-Release number of selected component (if applicable):
bash-completion-1.3-6.fc16.noarch

How reproducible:
Every time


Steps to Reproduce:
1.see above
2.
3.
  
Actual results:
nonsensical error spewing out at the point where I hit TAB

Expected results:
Completion of the /zoo partial name to /zooty

Additional info:
If I remove /etc/profile.d/bash_completion.sh, and re-login, everything
starts working fine again.

Comment 1 Ville Skyttä 2011-11-12 22:56:02 UTC
I can't reproduce.  Please do a "set -x" in a terminal, then invoke the "cd /zoo<TAB>", capture the output in a file and attach it here.  Also, is the behavior always the same no matter which dir you're in when invoking the completion?

Comment 2 Tom Horsley 2011-11-13 00:18:41 UTC
It seems to work fine if I comment out these definitions in my .bashrc
file:

function _pwd () {
   echo $PWD/
}
function _cd () {
   'cd' "$@" > /dev/null
   _pwd
}
alias cd=_cd

(I like the cd command to tell me the full path name of where I just
wound up, very handy for current directory tracking in an emacs shell).

With those defined, this is what set -x shows:

zooty> set -x
zooty> cd /zoo+ cd cd /zoo cd
bash: cd: cd: Not a directory
+ _pwd
+ echo /home/tom/
/home/tom/

Without those .bashrc defs, a humoungous set of shell gibberish is printed,
but /zoo does, in the end, get expanded to /zooty/

Comment 3 Ville Skyttä 2011-11-13 09:25:39 UTC
The function bash-completion uses for completing the cd command is also called _cd, and your bashrc definition overrides it with an incompatible one.

There has been some talk upstream to introduce a "namespace" for everything bash-completion uses/defines to make clashes like this less likely to happen (e.g. prefix all of its functions with _bashcomp_), but it is not clear when that might be implemented if at all.

I suggest renaming your _cd function so something else that doesn't clash with bash-completion.  By the way I believe your bashrc setup could be simplified to something like this, no need for aliases or other functions for this purpose:

cd() { builtin cd "$@" > /dev/null ; echo $PWD/ ; }


Note You need to log in before you can comment on or make changes to this bug.