fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

ANSI escape sequences are not stripped when stdout is redirected in cygwin. #179

Closed tyan0 closed 3 years ago

tyan0 commented 3 years ago

Overview

JANSI current git head (2.0.2-SNAPSHOT) failed to strip ANSI escape sequences when stdout is redirected in cygwin. Escape sequences in output of JANSI is expected to be enabled only when stdout is a TTY. However, current git head (2.0.2-SNAPSHOT) outputs escape sequences even when stdout is redirected to non-TTY in cygwin.

How to reproduce

  1. Install Maven.
  2. Replace JANSI with 2.0.2-SNAPSHOT.
  3. Execute mvn | less under cygwin.

Expected result

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.093 s
[INFO] Finished at: 2020-12-02T12:44:16+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
:

Actual result

[ESC[1;34mINFOESC[m] Scanning for projects...
[ESC[1;34mINFOESC[m] ESC[1m------------------------------------------------------------------------ESC[m
[ESC[1;34mINFOESC[m] ESC[1;31mBUILD FAILUREESC[m
[ESC[1;34mINFOESC[m] ESC[1m------------------------------------------------------------------------ESC[m
[ESC[1;34mINFOESC[m] Total time:  0.082 s
[ESC[1;34mINFOESC[m] Finished at: 2020-12-02T12:38:26+09:00
[ESC[1;34mINFOESC[m] ESC[1m------------------------------------------------------------------------ESC[m
[ESC[1;31mERRORESC[m] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> ESC[1m[Help 1]ESC[m
[ESC[1;31mERRORESC[m]
[ESC[1;31mERRORESC[m] To see the full stack trace of the errors, re-run Maven with the ESC[1m-eESC[m switch.
[ESC[1;31mERRORESC[m] Re-run Maven using the ESC[1m-XESC[m switch to enable full
:

The cause

I guess this is related to: https://github.com/fusesource/jansi-native/issues/23

tyan0 commented 3 years ago

I have confirmed that the issue is solved by commit 23e71d0abaefc4d7c8a5df1230cc2b3cdaa9c858. Thanks!