# std.Build: don't force all children to inherit color option · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/c6b5945356568f6ec70ca00f9a844bd180f8ca62)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: c6b5945356568f6ec70ca00f9a844bd180f8ca62

Requested commit: c6b5945356568f6ec70ca00f9a844bd180f8ca62

Commit: c6b5945356568f6ec70ca00f9a844bd180f8ca62

Tree: 24d4350469cf7fae42cbbabd697eb43b65e90640

Author: Matthew Lugg

Committer: Alex Rønne Petersen

## Message

```
std.Build: don't force all children to inherit color option

The build runner was previously forcing child processes to have their
stderr colorization match the build runner by setting `CLICOLOR_FORCE`
or `NO_COLOR`. This is a nice idea in some cases---for instance a simple
`Run` step which we just expect to exit with code 0 and whose stderr is
not being programmatically inspected---but is a bad idea in others, for
instance if there is a check on stderr or if stderr is captured, in
which case forcing color on the child could cause checks to fail.

Instead, this commit adds a field to `std.Build.Step.Run` which
specifies a behavior for the build runner to employ in terms of
assigning the `CLICOLOR_FORCE` and `NO_COLOR` environment variables. The
default behavior is to set `CLICOLOR_FORCE` if the build runner's output
is colorized and the step's stderr is not captured, and to set
`NO_COLOR` otherwise. Alternatively, colors can be always enabled,
always disabled, always match the build runner, or the environment
variables can be left untouched so they can be manually controlled
through `env_map`.

Notably, this fixes a failure when running `zig build test-cli` in a
TTY (or with colors explicitly enabled). GitHub CI hadn't caught this
because it does not request color, but Codeberg CI now does, and we were
seeing a failure in the `zig init` test because the actual output had
color escape codes in it due to 6d280dc.

```

## Parents

- [b38fb4bff31b76cbaa27157784139a71e290f2e9](https://git.cafe/gitcafe/zig/commit/b38fb4bff31b76cbaa27157784139a71e290f2e9?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/c6b5945356568f6ec70ca00f9a844bd180f8ca62?format=markdown)
