Sören Tempel 3d9c649158 ls: don't output any colors with TERM=dumb
The TERM variable is usually set to "dumb" to indicate that the terminal
does not support any ANSI escape sequences. Presently, ls does not honor
this variable and outputs colors anyhow which results in unreadable
output, unless the user explicitly disables colors using `ls
--color=never`. The rational behind this change is that ls should "just
work" by default, even on dumb terminals.

For this reason, this patch adds a check which additionally consults the
TERM variable before printing any colors. This is analogous to the
existing check for ensuring that standard output is a tty. As such,
colors can still be forced with `--color=force`, even if TERM is set to
dumb.

function                                             old     new   delta
is_TERM_dumb                                           -      40     +40
ls_main                                              579     598     +19
.rodata                                           103246  103251      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 64/0)               Total: 64 bytes

Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-04 22:39:10 +02:00
..
2020-08-13 17:12:56 +02:00
2020-12-14 18:25:28 +01:00
2020-12-17 11:22:44 +01:00
2021-02-03 20:52:40 +01:00
2021-02-03 20:43:07 +01:00
2020-10-01 03:07:22 +02:00
2020-08-13 17:12:56 +02:00
2021-04-14 17:52:18 +02:00
2021-02-03 20:52:40 +01:00
2018-07-17 15:04:17 +02:00
2020-12-17 20:53:43 +01:00
2018-12-08 15:35:24 +01:00
2021-04-14 17:52:18 +02:00

Please see the LICENSE file for copyright information (GPLv2)

libbb is BusyBox's utility library.  All of this stuff used to be stuffed into
a single file named utility.c.  When I split utility.c to create libbb, some of
the very oldest stuff ended up without their original copyright and licensing
information (which is now lost in the mists of time).  If you see something
that you wrote that is mis-attributed, do let me know so we can fix that up.

	Erik Andersen
	<andersen@codepoet.org>