Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j6Hxy-0007WW-8q for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2020 17:56:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j6Hxx-0004te-4d for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2020 17:56:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j6Hxw-0004tX-Pq for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2020 17:56:24 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j6Hxq-0003yc-GA for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2020 17:56:24 +0000 Received: by mail-wr1-x42c.google.com with SMTP id u6so11508758wrt.0 for ; Mon, 24 Feb 2020 09:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ENU9veGPyZYidfc5mzMbck4skcn5wcYz5meaHje+6fo=; b=BmZ5D/PRJ9+pXBL6C0u0sdKcRaqITffSyGOhMqNXwGbwS5NQ2pBkhbNl8DXsE8JcIL QADe/LMr7TKyj7DXbSVZvKs4f+38qnmxMMLuUJanFNOwqk8WZm3eiteelYrit4bnLDWF KoZZEq/awJu9qbNr1rvVGP4GQDNh1PxEm2F1Zz2woYKfA8KCksD2niSbFwAC5yhtVb4C cvc1cE3ubl+X+hHg6fYY3MdPIZMpU6TAylIMsMSVraAbnHwrq0oNcNWcQQSA3Xoa7PWA OS8rqfW3kacJAr/FmyXx9Lgr6g8ambxA44UonTCCcBD+VNumyQFfpJ8//X8OBgNmeywM lFXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ENU9veGPyZYidfc5mzMbck4skcn5wcYz5meaHje+6fo=; b=aNmf0q9fHCp3ncXGscnuQqZn4Ud5LTHQfKChKDJC3FRDqum9lfXVK7dss5J15oavWG A/BU3p0j9Di/IfixYbMJkH8Q/0qKSMCEbuaHUJLSLFMff84k/yVJPe8X3T8z+ztHg8/+ 8Y6f49mepO4HRwSineEcrC0HSUVtwV57+uBDUKHnpPrsBUg2MWK3CGcKm6uWuoCDGCOm ARrsXgBTapqy8TGIID4Jhaq29db5pCknmGnreZEfWEr3/r2bY9XC3QNjOQv7/IQFBhHi PKnHhk6WknzN8LiJPYHuKEquChQoL4C9H1a44Y1i7jVZU4H2pfiyAgqRtui3ifk9S+Ow ukkA== X-Gm-Message-State: APjAAAV9vhGyjgbth0VHu0OYkTJCn2m4nnD9BcL0rp9F8opfaOuFfPjl FGXrS16tFcYE/20Jb/Q5D9fRKCSc+5V8oYuYBac= X-Google-Smtp-Source: APXvYqwOfwlG3XikVejisjYxtuv0veoXyLIwTLzGH2/lyLQK2KTgdxwtF/N5pdQO87OPa5iGaTIc0krN2Nj+Exx8azM= X-Received: by 2002:a5d:5152:: with SMTP id u18mr66795775wrt.214.1582566977250; Mon, 24 Feb 2020 09:56:17 -0800 (PST) MIME-Version: 1.0 References: <16108-134692e97146b7bc@postgresql.org> <43AA0560298D1A4893896FDC52840EA1D9C74F7D@G08CNEXMBPEKD03.g08.fujitsu.local> In-Reply-To: From: =?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= Date: Mon, 24 Feb 2020 18:56:05 +0100 Message-ID: Subject: Re: BUG #16108: Colorization to the output of command-line has unproperly behaviors at Windows platform To: Michail Nikolaev Cc: Peter Eisentraut , "Tang, Haiying" , Thomas Munro , PostgreSQL Hackers Content-Type: multipart/mixed; boundary="000000000000835717059f5616fa" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000835717059f5616fa Content-Type: multipart/alternative; boundary="000000000000835714059f5616f8" --000000000000835714059f5616f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Feb 22, 2020 at 9:09 PM Michail Nikolaev wrote: > > I am not sure it is good idea to mix both patches because it adds some > confusion and makes it harder to merge each. > Maybe is it better to update current patch the way to reuse some > function later in [1]? > The patch was originaly reported for Windows, but looking into Peter's patch, I think this issue affects other systems unless we use stricter logic to detect a colorable terminal when using the "auto" option. Probably, the way to go is leaving this patch as WIN32 only and thinking about a future patch. > Also, regarding comment > > It is disabled by default, so it must be enabled to use color outpout. > > It is not true for new terminal, for example. Maybe it is better to > rephrase it to something like: "Check if TV100 support if enabled and > attempt to enable if not". > The logic I have seen on new terminals is that VT100 is supported but disabled. Would you find clearer? "Attempt to enable VT100 sequence processing. If it is not possible consider it as unsupported." Please find attached a patch addressing these comments. Regards, Juan Jos=C3=A9 Santamar=C3=ADa Flecha --000000000000835714059f5616f8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Feb 22, 2020 at 9:09 PM Micha= il Nikolaev <michail.nikolaev@gmail.com> wrote:

I am not sure it is good idea to mix both patches because it adds some
confusion and makes it harder to merge each.
Maybe is it better to update current patch the way to reuse some
function later in [1]?

The patch was or= iginaly reported for Windows, but looking into Peter's patch, I think t= his issue affects other systems unless we use stricter logic to detect a co= lorable terminal when using the "auto" option. Probably, the way = to go is leaving this patch as WIN32 only and thinking about a future patch= .
=C2=A0
Also, regarding comment
> It is disabled by default, so it must be enabled to use color outpout.=

It is not true for new terminal, for example. Maybe it is better to
rephrase it to something like: "Check if TV100 support if enabled and<= br> attempt to enable if not".

The log= ic I have seen on new terminals is that VT100 is supported but disabled. Wo= uld you find clearer? "Attempt to enable VT100 sequence processing. If= it is not possible consider it as unsupported."

Please find attached a patch addressing these comments.
<= br>
Regards,

Juan Jos=C3=A9 Santamar=C3= =ADa Flecha
--000000000000835714059f5616f8-- --000000000000835717059f5616fa Content-Type: application/octet-stream; name="v4-0001-command-line-colorization-on-windows.patch" Content-Disposition: attachment; filename="v4-0001-command-line-colorization-on-windows.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k70recdt0 ZGlmZiAtLWdpdCBhL3NyYy9jb21tb24vbG9nZ2luZy5jIGIvc3JjL2NvbW1vbi9sb2dnaW5nLmMK aW5kZXggYzc4YWU3OS4uZDU5ZWM4OCAxMDA2NDQKLS0tIGEvc3JjL2NvbW1vbi9sb2dnaW5nLmMK KysrIGIvc3JjL2NvbW1vbi9sb2dnaW5nLmMKQEAgLTMyLDYgKzMyLDM1IEBAIHN0YXRpYyBjb25z dCBjaGFyICpzZ3JfbG9jdXMgPSBOVUxMOwogI2RlZmluZSBBTlNJX0VTQ0FQRV9GTVQgIlx4MWJb JXNtIgogI2RlZmluZSBBTlNJX0VTQ0FQRV9SRVNFVCAiXHgxYlswbSIKIAorI2lmZGVmIFdJTjMy CisjaWZuZGVmIEVOQUJMRV9WSVJUVUFMX1RFUk1JTkFMX1BST0NFU1NJTkcKKyNkZWZpbmUgRU5B QkxFX1ZJUlRVQUxfVEVSTUlOQUxfUFJPQ0VTU0lORyAweDAwMDQKKyNlbmRpZgorCisvKgorICog QXR0ZW1wdCB0byBlbmFibGUgVlQxMDAgc2VxdWVuY2UgcHJvY2Vzc2luZy4KKyAqIElmIGl0IGlz IG5vdCBwb3NzaWJsZSBjb25zaWRlciBpdCBhcyB1bnN1cHBvcnRlZC4KKyAqLworc3RhdGljIGJv b2wKK2VuYWJsZV92dF9wcm9jZXNzaW5nKHZvaWQpCit7CisJLyogQ2hlY2sgc3RkZXJyICovCisJ SE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