Closed hellishvictor closed 3 weeks ago
This happens here: https://github.com/01mf02/jaq/blob/1699a7d1fc7ede6f728fcaa243f011137fcc220a/jaq/src/main.rs#L489-L500
Sadly this is part of a trait implementation for std::process::Termination
and I can't find a neat way of propagating the --color
cli option to this call. Making the cli options global would do it (as in using OnceCell) but that's a big change. Another path would be to try the supports_color crate.
Another path would be to try the supports_color crate.
That would be fine, I do have the NO_COLOR
variable included on my environment, because a lot of CLI out there use it.
@hellishvictor, thanks for your bug report. This should be corrected by my latest PR.
@kklingenberg, the way I took to propagate color settings was to call yansi::enable
.
I've compiled it and that fixes the #183, but when I added a plus sign by accident on the filter (_curl -s http://programminghistorian.org/assets/jq_rkm.json | jaq --color never .[]+_), it showed here:
←[31mError:←[0m Unexpected end of input, expected {, if, try, -, ", ., [, .., ( 3 8;5;246m╭←[0m←[38;5;246m─←[0m←[38;5;246m[←[0m<unknown>:1:5←[38;5;246m]←[0m ←[38;5;246m│←[0m ←[38;5;240m │←[0m ←[38;5;246m───╯←[0m
I've compiled it and that fixes the #183, but when I added a plus sign by accident on the filter (_curl -s http://programminghistorian.org/assets/jq_rkm.json | jaq --color never .[]+_), it showed here:
←[31mError:←[0m Unexpected end of input, expected {, if, try, -, ", ., [, .., ( 3 8;5;246m╭←[0m←[38;5;246m─←[0m←[38;5;246m[←[0m<unknown>:1:5←[38;5;246m]←[0m ←[38;5;246m│←[0m ←[38;5;240m │←[0m ←[38;5;246m───╯←[0m
I believe that you are not using the newest version on Git, because the newest version does never color the starting "Error:" string, yet in the output you posted, we can see ←[31mError:←[0m
, which indicates that it is colored.
Can you confirm my hypothesis?
Ok, I've downloaded the master again and compiled it, and this time it works fine:
Thank you very much!
Great, I'm happy to hear it! :)
Hi, I'm a user of Win 7 x64 and with cmd I have to use the "--color never" option, but it get bypassed when there's an error and shows:
←[31mError:←[0m undefined filter ←[38;5;246m╭←[0m←[38;5;246m─←[0m←[38;5;246m[←[0m<unknown>:1:14←[38;5;246m]←[0m ←[38;5;246m│←[0m ←[38;5;246m1 │←[0m ←[38;5;249m.←[0m←[38;5;249m[←[0m←[38;5;249m]←[0m←[38;5;249m ←[0m←[38;5;249m|←[0m ←[38;5;249m ←[0m←[38;5;249m.←[0m←[38;5;249mn←[0m←[38;5;249ma←[0m←[38;5;249mm←[0m←[38;5;249me←[0m←[38 ;5;249m,←[0m←[38;5;249m ←[0m←[31me←[0m←[31mv←[0m←[31me←[0m←[31mn←[0m←[31mt←[0m←[31ms←[0m←[38;5;249m[ ←[0m←[38;5;249m]←[0m ←[38;5;240m │←[0m ←[31m─←[0m←[31m─←[0m←[31m─←[0m←[31m┬←[0m←[31m─←[0m←[31m─←[0m ←[38;5;240m │←[0m ←[31m╰←[0m←[31m─←[0m←[31m─←[0m←[31m─←[0m←[31m─←[0m undefined fil ter ←[38;5;246m───╯←[0m
Cheers.