dalance / termbg

A Rust library for terminal background color detection
Apache License 2.0
80 stars 5 forks source link

Do not set the terminal to raw mode if it isn't actually a terminal #19

Closed aykevl closed 8 months ago

aykevl commented 1 year ago

It doesn't make sense to try to set a terminal as a raw terminal if it isn't actually a terminal. Worse, this may break tests that assume they can simply provide a pipe to a subprocess and expect the terminal will be unchanged.

See this PR, which needs this patch: https://github.com/sharkdp/bat/pull/2631


Note that this requires Rust 1.70 for the IsTerminal trait, if that's too new I can switch this PR to use the is-terminal crate instead. https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#isterminal

aykevl commented 8 months ago

@dalance can you take a look at this PR?

dalance commented 8 months ago

@aykevl Sorry for the late reply. I missed this PR. I want to keep minimum Rust version under 1.70, so could you change to use the is-terminal crate instead? If so, I'll merge and release as soon as possible.

aykevl commented 8 months ago

I've updated the PR! I've tested the PR with Rust 1.69, but according to the is-terminal crate it should work with Rust down to version 1.63.

Also I ran cargo fmt.

dalance commented 8 months ago

Thanks! I've released v0.4.4.

aykevl commented 8 months ago

That was my first Rust PR :) I'll be using it in bat.