GNU bug report logs - #55641
Using colours with grep

Previous Next

Package: grep;

Reported by: goncholden <goncholden <at> protonmail.com>

Date: Wed, 25 May 2022 20:49:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gary Johnson <garyjohn <at> spocom.com>
To: bug-grep <at> gnu.org
Subject: Re: bug#55641: Using colours with grep
Date: Sat, 28 May 2022 11:38:26 -0700
On 2022-05-28, goncholden wrote:
> I was trying to change the colours used for matching temporarily.
> But GREP_COLORS is global in nature.

An environment variable such as GREP_COLORS set by itself on the
command line persists in the environment after it has been set.  An
environment variable set on the same line as a command, such as

    GREP_COLORS='ms=01;32' grep this_pattern that_file

affects only the environment of that command, persists only for the
duration of that command, and does not affect the shell's
environment.

That may not be completely accurate, but it's close.

So, setting GREP_COLORS on the grep command line as above will
affect only that command and will not affect the "global" setting,
as you put it.

See the ENVIRONMENT section of the bash(1) man page.

Regards,
Gary





This bug report was last modified 2 years and 319 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.