From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <5990@protonmail.com> Received: from mail-4324.protonmail.ch (mail-4324.protonmail.ch [185.70.43.24]) by sourceware.org (Postfix) with ESMTPS id 8A6073856DF7 for ; Tue, 14 Jun 2022 08:01:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A6073856DF7 Date: Tue, 14 Jun 2022 08:01:45 +0000 To: "cygwin@cygwin.com" From: 5990 <5990@protonmail.com> Reply-To: 5990 <5990@protonmail.com> Subject: "cat" breaks ANSI codes on Windows Terminal when piping stdout to python or golang Message-ID: <1qctAGvnk1sjfU-ob9Y_DTSQIMpPGIn6lDmSoU0JKGPa_EDZkIMYP65gYufkeEVyPX0WCmJDQAJAmGf13IpPPHUmmchN17WDX4PyRxt2omE=@protonmail.com> Feedback-ID: 11940174:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 08:01:56 -0000 ## Bug: Piping the standard output of cat into the standard input of golang or pyth= on, makes the Windows Terminal render ANSI codes as arrows. For example: `\033[36m` turns into `=E2=86=90[36m` (or in base64'd UNICODE: `4oaQWzM2bQ= =3D=3D`) ## Environment: - cat v8.26 - Windows Terminal v1.12.10982.0 - golang version go1.17.2 windows/amd64 - python v3.7.7 colors.go ``` package main import "fmt" const colorReset =3D "\033[0m" const colorCyan =3D "\033[36m" func main(){ fmt.Print(string(colorCyan) + "golang-test" + string(colorReset) + "\n") } ``` color.py ``` from lolpython import lol_py lol_py("python-test") ``` domains.txt is an empty file (from my testing, the contents of domains.txt = do not affect this bug) ## What works: The following commands will successfuly output in cyan color `go run color.go` `go build color.go && color.exe` `go build color.go && cat domains.txt | color.exe` `go build color.go && echo a | color.exe` `go build color.go && type domains.txt | color.exe` `py -3.7 color.py` ## What triggers the bug: `cat domains.txt | go run color.go` OUTPUT: `=E2=86=90[36mgolang-test=E2=86=90[0m` `cat domains.txt | py -3.7 color.py` OUTPUT: `=E2=86=90[38;2;128;237;18mp=E2=86=90[0m=E2=86=90[38;2;139;231;12my= =E2=86=90[0m=E2=86=90[38;2;150;225;8mt=E2=86=90[0m=E2=86=90[38;2;161;217;5m= h=E2=86=90[0m=E2=86=90[38;2;172;209;2mo=E2=86=90[0m=E2=86=90[38;2;182;200;1= mn=E2=86=90[0m=E2=86=90[38;2;192;190;1m-=E2=86=90[0m=E2=86=90[38;2;201;180;= 1mt=E2=86=90[0m=E2=86=90[38;2;210;170;3me=E2=86=90[0m=E2=86=90[38;2;218;159= ;5ms=E2=86=90[0m=E2=86=90[38;2;226;148;9mt=E2=86=90[0m` Strangely enough, golang compiled executables work perfectly, but piping `c= at domains.txt | go run color.go` does not work. The workaround I had to go with is to use Windows's built-in `type` command= instead of `cat`. This was a tricky bug to track-down so I hope this repor= t helps hahah - ItsIgnacioPortal