X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E5A4383DBB1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1655243857;
	bh=NTzRcFL5eGx2pvV5Lp0SCBNM/xPbPBD4QIvWBMHnNwQ=;
	h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=aDwC+NT6e39qMzGV+/3W69Qz6ha4x1TTqeRG4flveCSbaX8emdbb5+gGw26QMk1hb
	 TF+MPOpfrtBWLTP05CNapgWYscTo2by8m7t0uN8wRG8EZtzen1qG1lzWCnTBQ2I2YK
	 yc7ahr0M0OCk5YthYd59kexicOKuAkMqToF0PqJg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
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
Subject: Re: "cat" breaks ANSI codes on Windows Terminal when piping stdout to
 python or golang
Message-ID: <AxmOCa0SO8GgPVfc9MByL2p1UzYqW62GNJ-CtHEt0b0ZubXAiVHLy5EG4HLs3HCGDBUTcnAuQckF1g_QlOSZMqVAcbeNBXcVAN0hA0aL7JY=@protonmail.com>
In-Reply-To: <VBZjByFkLXl6hq7JTHABwrGuZc-3em1fqYEdPY8YNDQeOJBUHPcp-s6ru9MSrxBoezXM8nYgvHS_tZERaEWyLiRNTvc6S0iMaP3zPhe_Xek=@protonmail.com>
References: <1qctAGvnk1sjfU-ob9Y_DTSQIMpPGIn6lDmSoU0JKGPa_EDZkIMYP65gYufkeEVyPX0WCmJDQAJAmGf13IpPPHUmmchN17WDX4PyRxt2omE=@protonmail.com>
 <20220614194753.e06a3ff4e6be224249956e50@nifty.ne.jp>
 <VBZjByFkLXl6hq7JTHABwrGuZc-3em1fqYEdPY8YNDQeOJBUHPcp-s6ru9MSrxBoezXM8nYgvHS_tZERaEWyLiRNTvc6S0iMaP3zPhe_Xek=@protonmail.com>
Feedback-ID: 11940174:user:proton
MIME-Version: 1.0
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 <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: 5990 via Cygwin <cygwin@cygwin.com>
Reply-To: 5990 <5990@protonmail.com>
Content-Type: text/plain; charset="utf-8"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 25ELvc1B014157

Ignore my previous email; I forgot to enable plain text mode.

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 same. cmd.exe does not support ANSI codes.

Also, what do you mean you can't reproduce the issue? Was it because of insufficient information, or because the commands worked perfectly on your system?

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 install 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 same. cmd.exe does not support ANSI codes.
>
> Also, what do you mean you can't reproduce the issue? Was it because of insufficient information, or because the commands worked perfectly on your system?
> 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 install lolpython`
> -------- Original Message --------
> On Jun. 14, 2022, 7:47 a.m., Takashi Yano < takashi.yano@nifty.ne.jp> wrote:
>
> >
> > On Tue, 14 Jun 2022 08:01:45 +0000 5990 via Cygwin wrote: > ## Bug: > Piping the standard output of cat into the standard input of golang or python, makes the Windows Terminal render ANSI codes as arrows. > > For example: > `\033[36m` turns into `←[36m` (or in base64'd UNICODE: `4oaQWzM2bQ==`) > > ## 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 = "\033[0m" > const colorCyan = "\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: `←[36mgolang-test←[0m` > > `cat domains.txt | py -3.7 color.py` > OUTPUT: `←[38;2;128;237;18mp←[0m←[38;2;139;231;12my←[0m←[38;2;150;225;8mt←[0m←[38;2;161;217;5mh←[0m←[38;2;172;209;2mo←[0m←[38;2;182;200;1mn←[0m←[38;2;192;190;1m-←[0m←[38;2;201;180;1mt←[0m←[38;2;210;170;3me←[0m←[38;2;218;159;5ms←[0m←[38;2;226;148;9mt←[0m` > > Strangely enough, golang compiled executables work perfectly, but piping `cat 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 report helps hahah I cannot reproduce your problem. My environment is: cygwin 3.3.5 cat 8.32 Windows Terminal 1.13.11431.0 go version go1.18.3 windows/amd64 What shell did you use?
 cygwin bash? cmd.exe? powershell? -- Takashi Yano

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

