-
Notifications
You must be signed in to change notification settings - Fork 74
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 escape codes appearing in piped output #21
Comments
Hi again ! Humm, I know the term library detects if the current terminal supports unicode, but I'm not sure it's aware you are piping the output to another program. I'll investigate into this tomorrow. |
I've had a quick look at the term library you're using, and it looks like it just checks for the TERM environment variable, and has no 'isatty' checks on stdout. There is a bug along the same lines there already Stebalien/term#54 too. I'm not sure if windows would suffer from the same problem. |
I can use atty crate to detect if the stdout is a tty or not (in the However, there is some cases where colorizing when output is redirected may be needed. Eg, when piping to What do you think about that ? Windows would not suffer from this (at least in the standard msdos-like sh*tty terminal) since colors are not rendered with ANSI characters, but with windows system calls instead. |
Thanks for that, this seems to fix the issue. Having a flag for printstd is probably the best you can do, I don't know of anyway around this - most unix commands have to do this as well though. |
Great. Instead of adding an argument flag to |
Just FYI, I added a comment to the upstream bug, since this seems like something that the term library should tell you Stebalien/term#54 (comment). |
👍 |
Fixed published on crates.io in |
I'm using this library for one of my programs, but I'm getting ANSI escape codes when piping the output (IE: The output isn't to a terminal). From a quick look at the code, there is a terminal detection feature. So I'm not sure why this is happening.
For reference, I'm on linux, using rxvt-unicode as my terminal And if it helps, here is where I'm calling your library - https://github.com/keeperofdakeys/Process-Query/blob/master/src/psq/main.rs#L21.
The text was updated successfully, but these errors were encountered: