The patch to improve color support on Windows has been commited [1], and I would like to share some of the discussion there that might affect this patch.
- The documentation/comments could make a better job of explaining the case of PG_COLOR equals 'always', explicitly saying that no checks are done about the output channel.
Aside from the decision about what the default coloring behaviour should be, there are parts of this patch that could be applied independently, as an improvement on the current state.
- The new function terminal_supports_color() should also apply when PG_COLOR is 'auto', to minimize the chances of seeing escape characters in the user terminal.
- The new entry in the documentation, specially as the PG_COLORS parameter seems to be currently undocumented. The programs that can use PG_COLOR would benefit from getting a link to it.
[1]
https://www.postgresql.org/message-id/20200302064842.GE32059%40paquier.xyz
Regards,
Juan José Santamaría Flecha