[Bash-completion-devel] [bash-completion-Bugs][312143] protect against user's personal binary preferences

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Wed Dec 9 00:18:24 UTC 2009


Bugs item #312143, was changed at 08/12/2009 00:29 by Raphaël Droz
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312143&group_id=100114

Status: Open
Priority: 3
Submitted By: Kevin Hunter (hunteke-guest)
Assigned to: Nobody (None)
Summary: protect against user's personal binary preferences 
Distribution: Ubuntu
Originally reported in: None
Milestone: None
Status: None
Original bug number: 


Initial Comment:
Since the bash_completion script is sourced /into/ a user's shell session, their personal preferences, e.g. aliases, would otherwise get used.  (e.g. alias grep='grep --color=always')  This is not what bash_completion needs.  In the example, this would return something like

$ sudo apt-get purge ggz[tab]
$ apt-get purge ggz^[\[m^[\[K^[\[m^[\[Kcore-bin

Instead, what we want is:

$ sudo apt-get purge ggz[tab]
$ sudo apt-get purge ggzcore-bin

Please see attached bashrc snippet and suggested patch to bash_completion.

Note: I did not change any of the comments.  Just the places where grep is actually used and called as 'grep'.

----------------------------------------------------------------------

Comment By: Raphaël Droz (gibboris-guest)
Date: 09/12/2009 00:18

Message:
I vote for using command (or 'quoting' the command, but 'command' prefix is nice for grep'ing bash-comp source).

I think this should also be made for other potentially aliased commands :
'cp', 'rm', 'mv', 'less' aren't used.
'cd' is : pkgtools, dpkg
'echo' is
'head', 'tail' are : genisoimage, cowsay, apache2ctl.
'ls' is always prefixed by 'command'
(personally I also have an alias for 'df'' and 'wget')

----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 08/12/2009 22:56

Message:
The patch has a number of problems, it cannot be applied, at least as is.

First, it is apparently against an old version of bash completion, current development version looks substantially different.  Second, it would "pollute" users' environment with the GREP variable.  Third, --color=auto is a GNU grep thing, it cannot be blindly used in bash completion.  Fourth, grep is not always installed in /bin.

Wouldn't simply replacing all occurrences of "grep" with "command grep" (it's already that way in a couple of places) be a good enough solution?  Ditto egrep and fgrep.  This wouldn't protect against nasty things in GREP_OPTIONS but I'm not sure there's much we can sanely do about those anyway.  Hmm... or we could always do "GREP_OPTIONS= command grep ..." but I'm not sure if that ugliness is worth it.  Or we could do that and also replace uses of grep with some other less problematic tool but...

----------------------------------------------------------------------

Comment By: Kevin Hunter (hunteke-guest)
Date: 08/12/2009 00:38

Message:
For passersby reading this, I'm aware that I may have an unexpected setup for my grep.  I explain why in the comments of the attached bashrc snippet, but suffice it to say, this what I have:

GREP_OPTIONS='--color=none'  # default to sane options
alias grep='grep --color=always'   # if I'm typing it, I most-likely want colors
alias less='less -R'   # enable pass-through (RAW) colors from grep

For reference, here's the discussion that convinced me put it the way I have it.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=475772#17


----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312143&group_id=100114



More information about the Bash-completion-devel mailing list