Closed michael-o closed 7 years ago
Can you explain what your test is and which line you're pointing at ?
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.
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.
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
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.
Just debugged the following:
I still see colors eventhough
isatty(fileno)
says 0 forstdout
.I have:
So the following line
kills this check on non-Cygwin.
There must be a better way for Cygwin since Unix is broken.
Any thoughts?