-
Notifications
You must be signed in to change notification settings - Fork 646
Confusing behaviour around ANSI capability detection when redirecting output to file #1790
Description
Information
- Windows
- Version: 0.49.1
- Terminal: Windows Terminal and Cmder 1.3.25.328
I'm seeing different behaviour around ANSI output when redirecting output to a file on Windows Terminal vs Cmder.
When running on Terminal and using > filename, ANSI capability is disabled:
Console properties
Height: 24
Width: 89
Encoding: Unicode (UTF-8)
ANSI codes: False
Interactive: True
Terminal: False
Unicode enabled: True
Colour system: EightBit
When running on Cmder and doing the same, it isn't. (The colour system is also not downgraded as it is with Terminal redirection, although I'm not sure of the impact, if any, of this).
Console properties
Height: 26
Width: 104
Encoding: Codepage - 437
ANSI codes: True
Interactive: True
Terminal: False
Unicode enabled: False
Colour system: TrueColor
Expected behaviour
This could be my misunderstanding, but when redirecting output to a file, I would expect the color ANSI codes to be stripped. Otherwise, those codes end up in the text file and garble the output without being interpreted when viewed in a text editor. I've gone through the ANSI detector code though and it is doing something more complicated than just checking for redirection though. (And we can see that in both cases it knows that it isn't outputting to a terminal.)
I'm not clear on why there would be a difference in behaviour depending on the terminal, when the output (a file) is the same.
Thanks in advance for any help with this issue.