exa icon indicating copy to clipboard operation
exa copied to clipboard

Don't assume connection to a tty when number of columns is set

Open goth-turtle opened this issue 3 years ago • 3 comments

This fixes the colorization issue from #955. Im not sure about introducing an unsafe block for that libc call though, can I get an opinion on that?

goth-turtle avatar Oct 31 '21 23:10 goth-turtle

I think the unsafe block is fine, but I don’t think this call is portable e.g. on Windows which we want to support in the future.

I think that we should leverage the fact that the terminal_size crate is cross-platform and that the function terminal_size::terminal_size() returns None if there’s no TTY, and it could be extracted from src/output/mod.rs and used in main.rs.

ariasuni avatar Nov 04 '21 12:11 ariasuni

Im not sure if I understood you correctly, but for now I just replaced the isatty() call with terminal_size().

I was also wondering if adding a testcase for this bug would be helpful? Ive looked into that already, but I dont think I entirely understand how to add a test yet, so I would need some help if you think I should add one.

goth-turtle avatar Nov 04 '21 22:11 goth-turtle

I suppose it’s something that you could test with Vagrant. See https://github.com/ogham/exa#testing-with-vagrant. Then it’s possible to add a test where exa is piped. Let me know if you want to do this or if you have questions.

I could do it but as you may have noticed by the time I took to comment your PR, I don’t have much time for exa these days, so it would be cool if you take a stab at it.

ariasuni avatar Dec 05 '21 19:12 ariasuni