Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 898224 - Portage should support the NO_COLOR environment variable
Summary: Portage should support the NO_COLOR environment variable
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Configuration (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL: https://no-color.org/
Whiteboard:
Keywords: InVCS
Depends on: 902189
Blocks:
  Show dependency tree
 
Reported: 2023-02-28 08:42 UTC by Ulrich Müller
Modified: 2024-11-11 22:46 UTC (History)
2 users (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 Ulrich Müller gentoo-dev 2023-02-28 08:42:14 UTC
The new quasi-standard for disabling ANSI color is to check for the NO_COLOR environment variable and disable color when the variable has a nonempty value.

See https://no-color.org/:
"Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color."

Unfortunately Portage uses NOCOLOR instead, and checks for its value differently (e.g. for NOCOLOR=false).

I suggest to update to the new standard. Presumably, the old variable should be kept in addition for some time, for backwards compatibility.
Comment 1 Ulrich Müller gentoo-dev 2023-02-28 09:35:31 UTC
Maybe this is also a chance to consolidate the check a little. Currently it is all over the place:

portage $ grep -r NOCOLOR | wc -l
37
Comment 2 hypersyd 2023-03-01 10:29:02 UTC
Does this "https://bugs.gentoo.org/898224" mean upgrading the logic to look for NOCOLOR as well as NO_COLOR ( where true is not an empty str )
Comment 3 Ulrich Müller gentoo-dev 2023-03-01 10:51:53 UTC
(In reply to Siddhanth Rathod from comment #2)
> Does this "https://bugs.gentoo.org/898224" mean upgrading the logic to look
> for NOCOLOR as well as NO_COLOR ( where true is not an empty str )

I think that the following would make sense:

Disable color if either:
- variable NO_COLOR has a non-empty value, _or_
- variable NOCOLOR has one of the values "true" or "yes".

Both variables would be taken from the environment or from make.conf, and the --color={y,n} option would override them.
Comment 5 hypersyd 2023-03-01 20:50:27 UTC
(In reply to Siddhanth Rathod from comment #4)
> https://github.com/gentoo/portage/actions/runs/4307349809/jobs/7512362761
> working on it

https://github.com/gentoo/portage/pull/1003
Comment 6 hypersyd 2023-03-01 22:07:58 UTC
(In reply to Siddhanth Rathod from comment #5)
> (In reply to Siddhanth Rathod from comment #4)
> > https://github.com/gentoo/portage/actions/runs/4307349809/jobs/7512362761
> > working on it
> 
> https://github.com/gentoo/portage/pull/1003

I rectify the issue indeed the logic is flawed !
Comment 7 Larry the Git Cow gentoo-dev 2023-03-21 02:36:22 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=0431aa7db28e69af309a8175ec9e13a23439e2fa

commit 0431aa7db28e69af309a8175ec9e13a23439e2fa
Author:     Siddhanth Rathod <xsiddhanthrathod@gmail.com>
AuthorDate: 2023-03-04 19:29:28 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-03-21 02:35:55 +0000

    emerge: respect NO_COLOR
    
    Bug: https://bugs.gentoo.org/898224
    Signed-off-by: Siddhanth Rathod <xsiddhanthrathod@gmail.com>
    Closes: https://github.com/gentoo/portage/pull/1003
    Signed-off-by: Sam James <sam@gentoo.org>

 NEWS                                                   |  7 ++++++-
 bin/ebuild                                             |  7 +++----
 bin/egencache                                          |  9 +++------
 bin/etc-update                                         |  1 +
 bin/isolated-functions.sh                              | 11 +++++++++--
 bin/portageq                                           |  6 ++----
 bin/save-ebuild-env.sh                                 |  2 +-
 lib/_emerge/AbstractEbuildProcess.py                   |  7 +++----
 lib/_emerge/actions.py                                 | 12 ++++++------
 lib/portage/_emirrordist/main.py                       |  2 +-
 lib/portage/dbapi/_MergeProcess.py                     |  5 ++---
 lib/portage/package/ebuild/_config/special_env_vars.py |  2 ++
 lib/portage/package/ebuild/_ipc/QueryCommand.py        |  6 ++----
 lib/portage/tests/__init__.py                          |  3 ++-
 lib/portage/tests/resolver/ResolverPlayground.py       |  4 ++--
 lib/portage/tests/runTests.py                          |  2 +-
 lib/portage/util/__init__.py                           | 11 +++++++++++
 17 files changed, 57 insertions(+), 40 deletions(-)
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-21 02:37:08 UTC
ulm, I'd appreciate if if you could run portage-9999 for a bit (or indefinitely, as I'd really love the testing) to confirm everything works as intended for you.

Thanks!
Comment 9 Ulrich Müller gentoo-dev 2023-03-23 20:48:08 UTC
(In reply to Sam James from comment #8)
> ulm, I'd appreciate if if you could run portage-9999 for a bit (or
> indefinitely, as I'd really love the testing) to confirm everything works as
> intended for you.

I've used 9999 without and with NO_COLOR for a couple of days, and I haven't noticed any problems.
Comment 10 Larry the Git Cow gentoo-dev 2023-04-07 10:07:00 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=05f0b3b184011060c86787f93e16a29002bdc54a

commit 05f0b3b184011060c86787f93e16a29002bdc54a
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-04-07 09:59:46 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-04-07 09:59:55 +0000

    sys-apps/portage: add 3.0.46
    
    Closes: https://bugs.gentoo.org/861659
    Closes: https://bugs.gentoo.org/877271
    Closes: https://bugs.gentoo.org/898224
    Closes: https://bugs.gentoo.org/899898
    Closes: https://bugs.gentoo.org/902189
    Closes: https://bugs.gentoo.org/903917
    Closes: https://bugs.gentoo.org/903926
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.46.ebuild | 285 +++++++++++++++++++++++++++++++++
 2 files changed, 286 insertions(+)
Comment 11 Larry the Git Cow gentoo-dev 2024-11-11 22:46:55 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=376afc18b75908ceb1d3c783b3c717d6b842c491

commit 376afc18b75908ceb1d3c783b3c717d6b842c491
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-11-11 09:37:14 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-11-11 10:36:30 +0000

    NOCOLOR -> NO_COLOR
    
    See https://no-color.org/. We already switched Portage and gentoolkit.
    
    Bug: https://bugs.gentoo.org/898224
    Bug: https://bugs.gentoo.org/902551
    Signed-off-by: Sam James <sam@gentoo.org>

 data/sandbox.bashrc   | 4 ++--
 etc/sandbox.conf      | 4 ++--
 libsbutil/sb_efuncs.c | 2 +-
 libsbutil/sbutil.h    | 2 +-
 src/environ.c         | 6 +++---
 tests/test-skel-0.c   | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)