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>
This patch changes the functions used to update timestamps in touch.
Before, utimes() and lutimes() were used, which had certain
disadvantages.
They are unable to handle nanosecond timestamps, and implementations of
certain features like -a and -m require running stat() in a loop.
Almost all implementations of utimes() and lutimes() are wrappers for
utimensat(), this is the case for glibc, ulibc and musl libc.
function old new delta
__futimens_time64 - 24 +24
__lutimes_time64 80 - -80
touch_main 539 456 -83
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 24/-163) Total: -139 bytes
Signed-off-by: urmum-69 <urmum69@snopyta.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Long options handling (getopt32 vs getopt32long) is done in libbb.h, no need to
care here of the same logic. This cleans the code a bit.
Also, --no-create was grouped as a SUSv3 option, where as the short -c was not.
Even if it is part of SUS, leave it out as was the short option.
v2: Fix for disabled ENABLE_LONG_OPTS. getopt32long does not like
IF_FEATURE_xxx() style conditionals... :/
Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
When using a file's times as reference, use both atime and mtime for the files
to be modified.
Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add missing -a and -m options to be fully SUSv3 compliant.
function old new delta
touch_main 415 510 +95
packed_usage 33824 33865 +41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 136/0) Total: 136 bytes
v2: Ignore -a/-m if not ENABLE_FEATURE_TOUCH_SUSV3.
Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
musl libc's mallocng free() may modify errno if kernel does not support
MADV_FREE which causes echo to echo with error when it shouldn't.
Future versions of POSIX[1] will require that free() leaves errno
unmodified but til then, do not rely free() implementation.
Should fix downstream issues:
https://github.com/alpinelinux/docker-alpine/issues/134https://gitlab.alpinelinux.org/alpine/aports/-/issues/12311
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The command 'nl -b n' should output no line numbers, just some
spaces as a placeholder followed by the actual file content.
Add tests for line numbering by cat and nl. The correct results
were obtained from coreutils.
function old new delta
print_numbered_lines 152 157 +5
.rodata 182456 182453 -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-3) Total: 2 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
<sys/sysmacros.h> is linux-only
FreeBSD defines makedev in sys/types.h already included in the libbb.h.
Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>