From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33525 invoked by alias); 3 Feb 2020 14:20:15 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 33472 invoked by uid 89); 3 Feb 2020 14:20:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:Sendmail, H*RU:Sendmail, H*r:authenticated X-HELO: conssluserg-02.nifty.com Received: from conssluserg-02.nifty.com (HELO conssluserg-02.nifty.com) (210.131.2.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Feb 2020 14:20:08 +0000 Received: from Express5800-S70 (ntsitm196171.sitm.nt.ngn.ppp.infoweb.ne.jp [125.0.207.171]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 013EJpS6000390 for ; Mon, 3 Feb 2020 23:19:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 013EJpS6000390 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1580739591; bh=2NMkbZdpHQ8+mzNOoXdcP/cTLAmBQfOqkRQ9zqlmiH4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=nLDGO0QQVs4EAsE7SLflHixPEKYdmjlJFaSsjEUbFtgXjG8hFxFYUBmGgNatndp3e 6yMWXHd6YWFvp1x1Jjx5P9Oo2gGsNBXGAC41ee0Q2sGx+EuKd+lgiRIKGnHAWws0Wo arM7GKma+qJ8IxcHnQmxnQzOO9LcIPgYT3Cjt1e32C6mzt1RLDpAz0/E1FZak54Z/H TftcyJc6gAx83ZE3D88MtJl+YWojGHDEVvhuecL621jGznwgR2AeO4ysrh0jWjftgQ CLEWqArm4PsX5HOa7ByY/u27wFTv/56Oa3yqxxE53XsJuns/NfeTQT1rYDL5EQaW9M NKpI4AL01KmTw== Date: Mon, 03 Feb 2020 14:20:00 -0000 From: Takashi Yano To: cygwin@cygwin.com Subject: Re: 3.1.x: Mangled input/output when calling non-cygwin programs Message-Id: <20200203231951.0b9e4ede90188c0fa20fe658@nifty.ne.jp> In-Reply-To: <20200203040033.375b2b75be4ab5b8b12b82bb@nifty.ne.jp> References: <7e3d947e-b178-30a3-589f-b48e6003fbb3@googlemail.com> <20200202185909.a3b3f8627438177e18171de3@nifty.ne.jp> <04b7abc1-3317-51c2-99e2-c8573458a5f1@googlemail.com> <20200203040033.375b2b75be4ab5b8b12b82bb@nifty.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00028.txt.bz2 On Mon, 3 Feb 2020 04:00:33 +0900 Takashi Yano wrote: > On Sun, 2 Feb 2020 13:18:03 +0100 > m0viefreak wrote: > > It seems that the cygwin1.dll does not care about TERM, but if a > > non-native application *uses* TERM for whatever reason things start to > > break. If indeed 'cygwin' is the right terminfo to be used, should the > > PTY code then somehow set TERM=cygwin in the non-native process? But > > what if the none-native program doesn't even know the 'cygwin' terminfo? > > This make sens only if apps use TERM *right way*. In other words, > if apps uses TERM in the manner of termcap or terminfo. I don't > think Maven does that. > > Now I am looking into jansi library which Maven uses, and found > it sets IS_CYGWIN flag according to TERM environmen. It seems > that IS_CYGWIN is set to false if TERM=cygwin. In this case, > jansi uses SetConsoleTextAttribute() call to set text color > rather than escape sequences such as ESC[31m. Ohterwise, escape > sequence is used. > > See: > https://github.com/fusesource/jansi/blob/master/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java > > New cygwin provide pure windows console for native apps, so > escape sequence is not handled correctly. This is the cause > of the problem 1) and 2). It may be a problem that TERM is > set even though pure windows console does not have the > capability which TERM environment declares. For the one > thought, it can make sense to unset TERM before execute > native-console apps. However, this does not solve the issue > of Maven. If Maven (jansi) handles TERM *correctly*, this > can be a solution. As for the problem 1) and 2), I think Maven (jansi) should be fixed rather than cygwin. I have applied the following patch to jansi, and confirmed this solves the problem 1) and 2). diff --git a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java index 628cad3..a5400c5 100644 --- a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java +++ b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java @@ -19,6 +19,10 @@ import static org.fusesource.jansi.internal.CLibrary.STDERR_FILENO; import static org.fusesource.jansi.internal.CLibrary.STDOUT_FILENO; import static org.fusesource.jansi.internal.CLibrary.isatty; +import static org.fusesource.jansi.internal.Kernel32.GetConsoleMode; +import static org.fusesource.jansi.internal.Kernel32.GetStdHandle; +import static org.fusesource.jansi.internal.Kernel32.STD_OUTPUT_HANDLE; + import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -54,10 +58,11 @@ public class AnsiConsole { */ static final boolean IS_CON_EMU_ANSI = "ON".equals(System.getenv("ConEmuANSI")); + static private int[] mode = {0}; static final boolean IS_CYGWIN = IS_WINDOWS && System.getenv("PWD") != null && System.getenv("PWD").startsWith("/") - && !"cygwin".equals(System.getenv("TERM")); + && GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode) == 0; static final boolean IS_MINGW_XTERM = IS_WINDOWS && System.getenv("MSYSTEM") != null -- Takashi Yano -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple