Re: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: "Tang, Haiying" <tanghy(dot)fnst(at)cn(dot)fujitsu(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform
Date: 2020-02-19 16:16:32
Message-ID: CAC+AXB3cTZKR8ry-T6-ui0qLMij+K_auxO9Lq9dHy1DBj+HDHQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, Feb 18, 2020 at 11:39 PM Michail Nikolaev <
michail(dot)nikolaev(at)gmail(dot)com> wrote:

>
> I have checked the patch source code and it seems to be working. But a
> few moments I want to mention:
>

Thanks for looking into this.

> I think it is not good idea to mix the logic of detecting the fact of
> TTY with enabling of the VT100 mode. Yeah, it seems to be correct for
> current case but a little confusing.
> Maybe is it better to detect terminal using *isatty* and later call
> *enable_vt_mode*?
>

Most of what enable_vt_mode() does is actually detecting the terminal, but
I can see why that is confusing without better comments.

> Also, it seems like if GetConsoleMode returns
> ENABLE_VIRTUAL_TERMINAL_PROCESSING flag already set - we could skip
> SetConsoleMode call (not a big deal of course).
>

Agreed.

The patch about making color by default [1] introduces the
function terminal_supports_color(), that I think is relevant for this
issue. Please find attached a new version based on that idea.

Also, adding Peter to weight on this approach.

[1] https://commitfest.postgresql.org/27/2406/

Regards,

Juan José Santamaría Flecha

Attachment Content-Type Size
v3-0001-command-line-colorization-on-windows.patch application/octet-stream 2.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-02-19 16:26:10 Re: BUG #16264: Server closed the connection unexpectedly
Previous Message Tom Lane 2020-02-19 16:05:05 Re: BUG #16266: Server crash on SELECT event_trigger-returning function

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-02-19 17:37:42 Re: Make ringbuffer threshold and ringbuffer sizes configurable?
Previous Message Anastasia Lubennikova 2020-02-19 16:14:03 Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.