Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI output stripping does not work if TERM is xterm #83

Closed
michael-o opened this issue Apr 26, 2017 · 5 comments
Closed

ANSI output stripping does not work if TERM is xterm #83

michael-o opened this issue Apr 26, 2017 · 5 comments

Comments

@michael-o
Copy link
Contributor

Just debugged the following:

$ ~/apache-maven-3.5.0/bin/mvnDebug  | less

I still see colors eventhough isatty(fileno) says 0 for stdout.

I have:

$ echo $TERM
xterm

So the following line

if (!isXterm() && !forceColored && rc == 0)

kills this check on non-Cygwin.

There must be a better way for Cygwin since Unix is broken.

Any thoughts?

@gnodet
Copy link
Member

gnodet commented Apr 26, 2017

Can you explain what your test is and which line you're pointing at ?

@michael-o
Copy link
Contributor Author

michael-o commented Apr 26, 2017

Yes, I wanted to test your libjansi.so for FreeBSD along with Maven 3.5.0. Started mvnDebug on that machine and wanted to see how Jansi behaves when I redirect stdout to a file. It should remove ANSI escapes. isatty does return 0, so dection is working, but the xterm check is killing it.

The shared library is loaded successfully.

The spurious line is https://github.com/fusesource/jansi/blob/master/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java#L122

Using $ TERM=ansi ~/apache-maven-3.5.0/bin/mvnDebug | less works though.

I can create a sample project if you want, isolated from Maven usecase.

@gnodet
Copy link
Member

gnodet commented Apr 26, 2017

I'm not sure why there is the XTERM check, but imho the behavior should be similar to commands such as ls, i.e. a flag which can have the values: always, auto, never.
I think the goal was to let color go through when it's supported. For example, on osx, the less commands handles colors nicely and less -r works well on FreeBSD too.

@gnodet gnodet closed this as completed in bb3d538 Apr 26, 2017
@gnodet
Copy link
Member

gnodet commented Apr 26, 2017

We already have the jansi.strip and jansi.force properties, so I think we're covered.
We should now be able to use

MAVEN_OPTS=-Djansi.force=true ~/apache-maven-3.5.0/bin/mvn | less -r

@michael-o
Copy link
Contributor Author

michael-o commented Apr 27, 2017

I am aware of that and this actually what we want to achieve in Maven. See here. We wan't to mimic ls(1) or grep(1) behavior. As for the force. We wan't actually abstract from Jansi. People shouldn't really know that this is a Jansi task but they simply rely Maven to do the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants