ut
ut copied to clipboard
Print no ANSI escape chars if the target isn't terminal
Expected Behavior
Print black/white text if the target isn't terminal
Actual Behavior
This is Visual Studio's WSL Dumb Console output:

isatty can do the job. To be more accurate, you can consider switching from iostreams to stdio, and use fileno on stdout.
Examples: doctest: https://github.com/doctest/doctest/blob/7b9885133108ae301ddd16e2651320f54cafeba7/doctest/doctest.h#L4125-L4127 catch2: https://github.com/catchorg/Catch2/blob/efb54926eec28900e020131930b35116075f6f84/src/catch2/internal/catch_console_colour.cpp#L173-L177