Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variable and/or command line option to prevent ninja from stripping color escape codes #916

Closed
ngladitz opened this issue Feb 25, 2015 · 6 comments

Comments

@ngladitz
Copy link

Ninja strips out color escape codes from e.g. gcc/clang when it detects that it isn't connected to a terminal.

In a CMake/Ninja based project the QtCreator IDE invokes ninja and is apparently capable of interpreting color codes.

It would be nice if ninja would provide the means to disable stripping of color codes in this case as to allow them to be visualized by QtCreator.

@evmar
Copy link
Collaborator

evmar commented Feb 25, 2015

Ninja doesn't strip the escapes. gcc/clang turn off the color when they're run under ninja.

There's more discussion here, that I think summarizes all the pros and cons of all the workarounds.
#174

@evmar evmar closed this as completed Feb 25, 2015
@evmar evmar reopened this Feb 25, 2015
@evmar
Copy link
Collaborator

evmar commented Feb 25, 2015

I totally misremembered the conclusion of that issue! Reopening.

@ngladitz
Copy link
Author

Yes, I did read up on that discussion as well.
To clarify I am forcing color output of gcc with -fdiagnostics-color=always.

@nico
Copy link
Collaborator

nico commented Feb 26, 2015

See also #672, #746.

mgiuffrida added a commit to mgiuffrida/ninja that referenced this issue Jan 27, 2017
Adds the general-purpose -o flag to address ninja-build#746, with options for
verbosity (ninja-build#480) and control sequence stripping (ninja-build#581, ninja-build#672, ninja-build#916). Also
provides the ability to enable both verbose and raw output as a
workaround for ninja-build#1214 without changing the existing verbose behavior.

-o verbose  show all command lines while building
-o quiet    hide command lines and outputs while building
-o raw      never strip control sequences from output
-o strip    always strip control sequences from output
-o color    strip most control sequences from output, but retain color codes

This patch does not affect Ninja's defaults of normal verbosity and
smart terminal detection for escape sequence stripping.

"-o color" is particularly useful for utilities like `head` and
`less -R` that interpret color codes from stdin and pass this colored
output to stdout. Any valid ANSI color code, of the form:

    `'ESC' '[' [ colors ] 'm'`

where `colors` is a semicolon-delimited list of optional integers:

   `[ n ] [ ';' colors ]`

is retained in its entirety when using "-o color" (any other CSI escape
sequences besides ANSI color codes are still stripped for non-smart
terminals).
mgiuffrida added a commit to mgiuffrida/ninja that referenced this issue Jan 27, 2017
Adds the general-purpose -o flag to address ninja-build#746, with options for
verbosity (ninja-build#480) and control sequence stripping (ninja-build#581, ninja-build#672, ninja-build#916). Also
provides the ability to enable both verbose and raw output as a
workaround for ninja-build#1214 without changing the existing verbose behavior.

-o verbose  show all command lines while building
-o quiet    hide command lines and outputs while building
-o raw      never strip control sequences from output
-o strip    always strip control sequences from output
-o color    strip most control sequences from output, but retain color codes

This patch does not affect Ninja's defaults of normal verbosity and
smart terminal detection for escape sequence stripping.

"-o color" is particularly useful for utilities like `head` and
`less -R` that interpret color codes from stdin and pass this colored
output to stdout. Any valid ANSI color code, of the form:

    `'ESC' '[' [ colors ] 'm'`

where `colors` is a semicolon-delimited list of optional integers:

   `[ n ] [ ';' colors ]`

is retained in its entirety when using "-o color" (any other CSI escape
sequences besides ANSI color codes are still stripped for non-smart
terminals).
mgiuffrida added a commit to mgiuffrida/ninja that referenced this issue Jan 27, 2017
Adds the general-purpose -o flag to address ninja-build#746, with options for
verbosity (ninja-build#480) and control sequence stripping (ninja-build#581, ninja-build#672, ninja-build#916). Also
provides the ability to enable both verbose and raw output as a
workaround for ninja-build#1214 without changing the existing verbose behavior.

-o verbose  show all command lines while building
-o quiet    hide command lines and outputs while building
-o raw      never strip control sequences from output
-o strip    always strip control sequences from output
-o color    strip most control sequences from output, but retain color codes

This patch does not affect Ninja's defaults of normal verbosity and
smart terminal detection for escape sequence stripping.

"-o color" is particularly useful for utilities like `head` and
`less -R` that interpret color codes from stdin and pass this colored
output to stdout. Any valid ANSI color code, of the form:

    `'ESC' '[' [ colors ] 'm'`

where `colors` is a semicolon-delimited list of optional integers:

   `[ n ] [ ';' colors ]`

is retained in its entirety when using "-o color" (any other CSI escape
sequences besides ANSI color codes are still stripped for non-smart
terminals).
timniederhausen pushed a commit to timniederhausen/ninja that referenced this issue Sep 19, 2017
Adds the general-purpose -o flag to address ninja-build#746, with options for
verbosity (ninja-build#480) and control sequence stripping (ninja-build#581, ninja-build#672, ninja-build#916). Also
provides the ability to enable both verbose and raw output as a
workaround for ninja-build#1214 without changing the existing verbose behavior.

-o verbose  show all command lines while building
-o quiet    hide command lines and outputs while building
-o raw      never strip control sequences from output
-o strip    always strip control sequences from output
-o color    strip most control sequences from output, but retain color codes

This patch does not affect Ninja's defaults of normal verbosity and
smart terminal detection for escape sequence stripping.

"-o color" is particularly useful for utilities like `head` and
`less -R` that interpret color codes from stdin and pass this colored
output to stdout. Any valid ANSI color code, of the form:

    `'ESC' '[' [ colors ] 'm'`

where `colors` is a semicolon-delimited list of optional integers:

   `[ n ] [ ';' colors ]`

is retained in its entirety when using "-o color" (any other CSI escape
sequences besides ANSI color codes are still stripped for non-smart
terminals).
@pseyfert
Copy link
Contributor

@jhasse
Copy link
Collaborator

jhasse commented Nov 13, 2018

Fixed by bf7107b.

@jhasse jhasse closed this as completed Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants