Before this change, when using -o <filename> you end up with \x1b[39m\x1b[0m appended to the end of your file.
There is logic to avoid this elsewhere (by setting FG_RST, ST_RST etc to empty string) but this happens at module level before the CLI arguments are parsed.
_exit is also defined (and used) before the arguments are parsed, which means we can't check args.output.
We can safely use sys.stdout.isatty() because by the time the _exit(0) is called at the end, sys.stdout has been overwritten to be the file specified in the -o arg, and won't be a tty any more.
Before this change, when using
-o <filename>
you end up with\x1b[39m\x1b[0m
appended to the end of your file.There is logic to avoid this elsewhere (by setting
FG_RST
,ST_RST
etc to empty string) but this happens at module level before the CLI arguments are parsed._exit
is also defined (and used) before the arguments are parsed, which means we can't checkargs.output
.We can safely use
sys.stdout.isatty()
because by the time the_exit(0)
is called at the end,sys.stdout
has been overwritten to be the file specified in the-o
arg, and won't be a tty any more.