[Toybox] Question about --color

Rob Landley rob at landley.net
Wed Aug 10 03:42:03 PDT 2022


Since diff also supports --color I'm trying to genericize the plumbing into lib
but would it make sense for things like ls that can color their output to just
do that by default?

Right now if you say --color that defaults to --color=auto but if you DON'T say
--color it's equivalent to --color=never. So you can set up a shell alias to
color the output, but you won't just naturally get it.

Except... it's checking if stdout is a tty? Shouldn't it always be ok to output
color escapes to a tty, and when you don't want it to you can say say
--color=never or pipe it to cat or something? Stuff like ABC="$(command)" is
automatically going to lose the color because output isn't to a tty.

So it seems like when you DON'T say --color, ls and diff should default to
--color=auto? And that way we don't have to alias them?

Rob


More information about the Toybox mailing list