From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <5990@protonmail.com> Received: from mail-4318.protonmail.ch (mail-4318.protonmail.ch [185.70.43.18]) by sourceware.org (Postfix) with ESMTPS id 37F1D3874754 for ; Tue, 14 Jun 2022 21:56:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37F1D3874754 Date: Tue, 14 Jun 2022 21:56:39 +0000 To: takashi.yano@nifty.ne.jp, cygwin@cygwin.com From: 5990 <5990@protonmail.com> Reply-To: 5990 <5990@protonmail.com> Subject: Re: "cat" breaks ANSI codes on Windows Terminal when piping stdout to python or golang Message-ID: In-Reply-To: References: <1qctAGvnk1sjfU-ob9Y_DTSQIMpPGIn6lDmSoU0JKGPa_EDZkIMYP65gYufkeEVyPX0WCmJDQAJAmGf13IpPPHUmmchN17WDX4PyRxt2omE=@protonmail.com> <20220614194753.e06a3ff4e6be224249956e50@nifty.ne.jp> 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.4 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, RCVD_IN_MSPIKE_H2, 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 21:56:50 -0000 Ignore my previous email; I forgot to enable plain text mode. I ran all commands on cmd from within Windows Terminal. Note that running c= md.exe directly, and running cmd from the Windows Terminal is not the same.= cmd.exe does not support ANSI codes. Also, what do you mean you can't reproduce the issue? Was it because of ins= ufficient information, or because the commands worked perfectly on your sys= tem? By the way, I've attached my cygcheck.out; I forgot to attach it at first. = I've redacted my username and computer name. I noticed you didn't include python information in your environment. You ca= n install the missing lolpython dependency from PiPy by running `pip instal= l lolpython` Sent with Proton Mail secure email. ------- Original Message ------- On Tuesday, June 14th, 2022 at 9:53 PM, 5990 <5990@protonmail.com> wrote: > I ran all commands on cmd from within Windows Terminal. Note that running= cmd.exe directly, and running cmd from the Windows Terminal is not the sam= e. cmd.exe does not support ANSI codes. > > Also, what do you mean you can't reproduce the issue? Was it because of i= nsufficient information, or because the commands worked perfectly on your s= ystem? > By the way, I've attached my cygcheck.out; I forgot to attach it at first= . I've redacted my username and computer name. > > I noticed you didn't include python information in your environment. You = can install the missing lolpython dependency from PiPy by running `pip inst= all lolpython` > -------- Original Message -------- > On Jun. 14, 2022, 7:47 a.m., Takashi Yano < takashi.yano@nifty.ne.jp> wro= te: > > > > > On Tue, 14 Jun 2022 08:01:45 +0000 5990 via Cygwin wrote: > ## Bug: > P= iping the standard output of cat into the standard input of golang or pytho= n, makes the Windows Terminal render ANSI codes as arrows. > > For example:= > `\033[36m` turns into `=E2=86=90[36m` (or in base64'd UNICODE: `4oaQWzM2= bQ=3D=3D`) > > ## Environment: > - cat v8.26 > - Windows Terminal v1.12.109= 82.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(colo= rCyan) + "golang-test" + string(colorReset) + "\n") > } > ``` > > > color.p= y > ``` > from lolpython import lol_py > > lol_py("python-test") > ``` > > = > domains.txt is an empty file (from my testing, the contents of domains.tx= t 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 bui= ld 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 dom= ains.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;23= 7;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;5mh=E2=86=90[0m=E2=86=90[38;2;17= 2;209;2mo=E2=86=90[0m=E2=86=90[38;2;182;200;1mn=E2=86=90[0m=E2=86=90[38;2;1= 92;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 `cat domains.txt | go run color.go` does not wo= rk. > The workaround I had to go with is to use Windows's built-in `type` c= ommand instead of `cat`. This was a tricky bug to track-down so I hope this= report helps hahah I cannot reproduce your problem. My environment is: cyg= win 3.3.5 cat 8.32 Windows Terminal 1.13.11431.0 go version go1.18.3 window= s/amd64 What shell did you use? cygwin bash? cmd.exe? powershell? -- Takash= i Yano