Tobias Geerinckx-Rice wrote:
Björn Höfling wrote:
ls has a colored output. Nice.
ls | less has ugly escape sequences. Only ls --color=no | less
works.
I'd be surprised if ‘ls | less -R’ didn't (and that would be a
bug).
Otherwise, this is standard behaviour for both ‘ls’ and ‘less’.
Apologies, I made a reado.
‘ls | $foo’ should indeed detect a missing tty and stop spewing
colour automatically. At least if ‘ls’ is properly aliased to ‘ls
--color=auto’.
Instead, it is aliased[0] to use ‘--color’ — short for ‘ls
--color=always’ — for reasons I cannot understand. We do the same
for ‘grep’.
Perhaps it was assumed that ‘--color’ on its own implies ‘auto’
instead of ‘always’ (I could see how that could happen)? Or
‘--color=auto’ is too cautious, and disables colour in a situation
where the author expects it? In that case I don't think the
trade-off is worth it.
On the other hand, what I consider an obvious bug has been around
since literal forever[1], so maybe I'm missing something obvious
here. I've CC'd the original author. If everyone agrees or nobody
responds, I'd like to change it to something less aggressive
before 0.15.[2]
What? Not sure yet. I'm not even sure this should be handled by
aliases at all. Our default ‘ls’ alias also adds a ‘-p’, which is
probably valid [although I find it useless and annoying and
disable it], but colours for both commands can also be controlled
through the {LS,GREP}_COLORS variables which seems like a better
fit for distro defaults like these. We can even change the
colours! But let's not.
Oh, I don't know.
This is the kind of trivial bug that would've put me off a distro,
I guess.
Kind regards,
T G-R
[0]: in gnu/system/shadow.scm
[1]: 2013, at least: 0b86a82dc7e649e4ae551edefba445690a315b83
[2]: I'm already doing so in my own .bashrc, which has drifted
away from Guix's current upstream version, which is its own little
annoying gotcha.