Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 434170 - app-shells/bash - /etc/bash/bashrc should use GREP_OPTIONS to set *grep --color
Summary: app-shells/bash - /etc/bash/bashrc should use GREP_OPTIONS to set *grep --color
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-06 23:41 UTC by Dave Kemper
Modified: 2014-09-29 14:31 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Kemper 2012-09-06 23:41:01 UTC
Under the "Enable colors for ls, etc." block of /etc/bash/bashrc, colors are enabled for grep by defining the alias grep='grep --colour=auto'.  However, similar aliases are not defined for fgrep and egrep, leaving the system default color behavior of the various greps inconsistent.

A better solution than aliasing all the grep flavors would be to define GREP_OPTIONS="--colour=auto": all the greps honor this environment variable.
Comment 1 SpanKY gentoo-dev 2012-09-13 07:36:04 UTC
i'm a bit hesitant for fear of breaking scripts and general environment pollution.  aliases are good because they don't leak out of the active env.
Comment 2 Dave Kemper 2012-09-13 16:01:49 UTC
Default behavior among the flavors of grep should be consistent.  Having /etc/bash/bashrc alias all three standard greps is a reasonable way to achieve this.  (My original Summary line for this bug said merely that bashrc "handles greps inconsistently."  I don't know why Jeroen changed it; the GREP_OPTIONS idea was merely a suggested fix, not part of the bug description.)

Setting GREP_OPTIONS seemed cleaner to me, but I didn't consider its effect on scripts.  Still, I'd expect the effect to be minimal, as *grep's --colour=auto option only adds the color-producing escape sequences when output is a terminal.
Comment 3 SpanKY gentoo-dev 2012-09-13 21:29:12 UTC
(In reply to comment #2)

i'm not disagreeing on consistent behavior.  just debating adding more aliases or going with the env var.
Comment 4 SpanKY gentoo-dev 2012-09-13 21:46:59 UTC
should be all set now in the tree; thanks for the report!

Commit message: Add egrep/fgrep colour aliases too
http://sources.gentoo.org/app-shells/bash/files/bashrc?r1=1.20&r2=1.21