Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 782910 - sys-apps/portage: add variable like PORTAGE_LOG_FILTER_FILE_CMD that's used to filter stdout if it's not a tty
Summary: sys-apps/portage: add variable like PORTAGE_LOG_FILTER_FILE_CMD that's used t...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Configuration (show other bugs)
Hardware: All All
: Normal enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-15 01:32 UTC by Zac Medico
Modified: 2021-09-25 02:31 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 Zac Medico gentoo-dev 2021-04-15 01:32:03 UTC
It would be good to have one variable for tty console output, and another variable for the case where stdout is not a tty.
Comment 1 wolfgang 2021-04-15 01:49:29 UTC
Ideally I think the default behaviour should be to strip ansi escape sequences when stdout out is not a tty - I've seen this as the default in other programs (i.e. hledger, git diff) and it tends to work well for typical workflows.
Comment 2 Zac Medico gentoo-dev 2021-04-15 07:59:27 UTC
As it is, we have tty detection linked to the NOCOLOR environment variable, via this code:

> bin/isolated-functions.sh:case "${NOCOLOR:-false}" in
> bin/isolated-functions.sh-      yes|true)
> bin/isolated-functions.sh-              __unset_colors
> bin/isolated-functions.sh-              ;;
> lib/_emerge/actions.py- elif settings.get('TERM') == 'dumb' or \
> lib/_emerge/actions.py:         not sys.stdout.isatty():
> lib/_emerge/actions.py-         portage.output.havecolor = 0
> lib/_emerge/actions.py-         settings["NOCOLOR"] = "true"
> lib/_emerge/actions.py-         settings.backup_changes("NOCOLOR")
> eclass/cargo.eclass:    $([[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo "color = 'never'")
> eclass/cargo.eclass:            [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && export CARGO_TERM_COLOR=never
> eclass/cmake-utils.eclass:      [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
> eclass/cmake.eclass:    if [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]]; then
> eclass/ruby-ng.eclass:# which also respects TEST_VERBOSE and NOCOLOR environment variables.
> eclass/ruby-ng.eclass:  case ${NOCOLOR} in
> eclass/ruby-ng.eclass:# which also respects TEST_VERBOSE and NOCOLOR environment variables.
> eclass/ruby-ng.eclass:  case ${NOCOLOR} in
> eclass/ruby-ng.eclass:# This also respects TEST_VERBOSE and NOCOLOR environment variables.
> eclass/ruby-ng.eclass:  case ${NOCOLOR} in
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-04-15 08:07:14 UTC
(Worth noting that NO_COLOR with the underscore seems to be a new standard being converged on: https://no-color.org)