Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 782910

Summary: sys-apps/portage: add variable like PORTAGE_LOG_FILTER_FILE_CMD that's used to filter stdout if it's not a tty
Product: Portage Development Reporter: Zac Medico <zmedico>
Component: Core - ConfigurationAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: enhancement CC: gentoo, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=814656
Whiteboard:
Package list:
Runtime testing required: ---

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)