Bug 98627 - bash-completion cannot complete `mount xyz` properly
Bug#: 98627 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: trivial Priority: P2
Resolution: FIXED Assigned To: shell-tools@gentoo.org Reported By: korngerd@yahoo.com
Component: Applications
URL: 
Summary: bash-completion cannot complete `mount xyz` properly
Keywords:  
Status Whiteboard: 
Opened: 2005-07-10 23:02 0000
Description:   Opened: 2005-07-10 23:02 0000
Anytime you have a grep alias set to "grep --color=always", bash-completion
fails to complete `mount` commands properly.  It uses the aliased grep to spit
out the possible mount locations.  Line 655 of /etc/bash_completion should have:
  /etc/fstab | grep --color=never "^$cur" ) )
along with any other "grep" instances.

Reproducible: Always
Steps to Reproduce:
1. alias "grep=grep --color=always"
2. mount / [tab]
Actual Results:  
^[\[01\;31m/^[\[00m gets spit out

Expected Results:  
/ should get spit out (along with any other possible mounts under /).

------- Comment #1 From Aaron Walker (RETIRED) 2005-07-13 05:03:30 0000 -------
Using --color=never is not a viable solution.  What if grep is not GNU grep?

I'm thinking more of closing this WONTFIX and updating the ebuild's pkg_postinst
instructions to state that /etc/profile.d/bash-completion should be sourced
*before* you declare anything else in ~/.bashrc, as there's no guarantee that
any aliases you set wont be a) misused unintentionally as in this case, or b)
re-set to something else by bash-completion (it does set some aliases under
certain conditions).

I am willing to listen to any alternative solutions you may have, however.

------- Comment #2 From *nyamo* 2005-07-13 12:43:56 0000 -------
(In reply to comment #1)
> I'm thinking more of closing this WONTFIX and updating the ebuild's pkg_postinst
> instructions to state that /etc/profile.d/bash-completion should be sourced
> *before* you declare anything else in ~/.bashrc, as there's no guarantee that
> any aliases you set wont be a) misused unintentionally as in this case, or b)
> re-set to something else by bash-completion (it does set some aliases under
> certain conditions).

Actually, that might be a better solution to this :)  A warning at the end would
solve any other alias issues as well.

------- Comment #3 From Aaron Walker (RETIRED) 2005-07-14 00:34:47 0000 -------
I've updated the pkg_postinst of existing ebuilds, and made note of this bug,
giving instructions that any aliases set should be done after sourcing
/etc/profile.d/bash-completion.

Might as well mark this FIXED, since that's the reasonable resolution.

------- Comment #4 From Kenyon Ralph 2005-07-20 10:40:31 0000 -------
Just setting aliases after sourcing /etc/profile.d/bash-completion doesn't mean
the alias will work.  I can't get an alias of rm='rm -iv' when bash-completion
has been sourced.

------- Comment #5 From Kenyon Ralph 2005-07-20 11:12:16 0000 -------
(In reply to comment #4)
> Just setting aliases after sourcing /etc/profile.d/bash-completion doesn't mean
> the alias will work.  I can't get an alias of rm='rm -iv' when bash-completion
> has been sourced.

Nevermind, I'm experiencing Bug 99540.

------- Comment #6 From Nilton Volpato 2007-06-02 05:30:40 0000 -------
Another solution or this would be to prefix grep with the bash "command"
builtin, so that any aliases are ignored. This would always work, and one would
not need to worry about the order of defining aliases.