sway icon indicating copy to clipboard operation
sway copied to clipboard

Forc: colored output to go only to a tty

Open segfault-magnet opened this issue 3 years ago • 1 comments

If you redirect the stdout/stderr from Forc to something other than a tty you're still going to have ANSI escape codes for coloring:

❯ forc build |& cat --show-all
^[[0m^[[32m  Compiled library "core".$
^[[0m^[[0m^[[32m  Compiled library "std".$
^[[0m^[[0m^[[32m  Compiled contract "transaction_block_height".$
^[[0m  Bytecode size is 84 bytes.$

The convention for CLI tools is to check (via isatty) if what you're writing to is a tty before using escape codes.

segfault-magnet avatar Jul 22 '22 13:07 segfault-magnet

Cargo also provides a --color flag for controlling this, we might want to consider doing something similar too.

We should consider addressing #2373 first as it would simplify adding an isatty check.

mitchmindtree avatar Jul 25 '22 06:07 mitchmindtree