ash and hush correctly use the value of HOME for tilde expansion.
However the line editing code in libbb obtains the user's home
directory by calling getpwuid(). Thus tildes in tab completion
and prompts may be interpreted differently than in tilde expansion.
When the line editing code is invoked from a shell make it use the
shell's interpretation of tilde. This is similar to how GNU readline
and bash collaborate.
function old new delta
get_homedir_or_NULL 29 72 +43
optschanged 119 126 +7
hush_main 1204 1211 +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0) Total: 57 bytes
v2: Always check for HOME before trying the password database: this
is what GNU readline does.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"
function old new delta
.rodata 108586 108460 -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes
text data bss dec hex filename
970412 4219 1848 976479 ee65f busybox_old
970286 4219 1848 976353 ee5e1 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
- This can act as memory barrier in clang to avoid
read before assign of a const ptr
Signed-off-by: LoveSy <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add some tests which coreutils realpath pass but BusyBox realpath
fails (bar one). Adjust xmalloc_realpath_coreutils() so the tests
pass:
- Expand symbolic links before testing whether the last path component
exists.
- When the link target is a relative path canonicalize it by passing
it through xmalloc_realpath_coreutils() as already happens for
absolute paths.
- Ignore trailing slashes when finding the last path component and
correctly handle the case where the only slash is at the start of
the path. This requires ignoring superfluous leading slashes.
- Undo all changes to the path so error messages from the caller show
the original filename.
function old new delta
xmalloc_realpath_coreutils 214 313 +99
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
While at it, change all "__asm__" to "asm"
Co-authored-by: canyie <31466456+canyie@users.noreply.github.com>
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Allow ISO 8601 style dates to include a timezone offset. Like
the '@' format these dates aren't relative to the user's current
timezone and shouldn't be subject to DST adjustment.
- The implementation uses the strptime() '%z' format specifier.
This an extension which may not be available so the use of
timezones is a configuration option.
- The 'touch' applet has been updated to respect whether DST
adjustment is required, matching 'date'.
function old new delta
parse_datestr 624 730 +106
static.fmt_str 106 136 +30
touch_main 388 392 +4
date_main 818 819 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 141/0) Total: 141 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Process substitution is a Korn shell feature that's also available
in bash and some other shells. This patch implements process
substitution in ash when ASH_BASH_COMPAT is enabled.
function old new delta
argstr 1386 1522 +136
strtodest - 52 +52
readtoken1 3346 3392 +46
.rodata 183206 183250 +44
unwindredir - 28 +28
cmdloop 365 372 +7
static.spclchars 10 12 +2
cmdputs 380 367 -13
exitreset 86 69 -17
evalcommand 1754 1737 -17
varvalue 675 634 -41
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/4 up/down: 315/-88) Total: 227 bytes
text data bss dec hex filename
953967 4219 1904 960090 ea65a busybox_old
954192 4219 1904 960315 ea73b busybox_unstripped
v2: Replace array of file descriptors with a linked list.
Include tests that were unaccountably omitted from v1.
v3: Update linked list code to the intended version.
v4: Change order of conditional code in cmdputs().
v5: Use existing popredir() mechanism to manage file descriptors.
v6: Rebase to latest version of BusyBox ash. Reduce code churn.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
While at it, rename bb_signals_recursive_norestart() to bb_signals_norestart():
"recursive" was implying we are setting SA_NODEFER allowing signal handler
to be entered recursively, but we do not do that.
function old new delta
bb_signals_norestart - 70 +70
startservice 380 394 +14
bb_signals_recursive_norestart 70 - -70
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 84/-70) Total: 14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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>
Most BusyBox applets respond to the '--help' option by printing
a usage message. This is normally handled by busybox_main() so
applet main routines don't have support for '--help'.
In standalone shell mode with FEATURE_SH_NOFORK enabled nofork
applets are invoked directly, bypassing busybox_main(). This
results in inconsistent handling of '--help':
- applets which call getopt() report "unrecognized option '--help'"
and print help anyway;
- realpath says "--help: No such file or directory" and doesn't
print help;
- usleep says "invalid number '--help'" and doesn't print help.
Avoid inconsistency by checking for '--help' in run_nofork_applet().
Bug found by Ron Yorston.
function old new delta
show_usage_if_dash_dash_help - 70 +70
run_nofork_applet 347 362 +15
run_applet_no_and_exit 432 365 -67
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67) Total: 18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
"In function 'sprint_status48':
error: format not a string literal and no format arguments"
function old new delta
sprint_status48 160 158 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
FreeBSD is not using <utmp.h> and does not define _PATH_UTMPX.
Tested with busybox applets depending on FEATURE_UTMP (e.g. who, users, etc)
Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
FreeBSD uses setpgrp(pid_t, pid_t)
This patch makes crond.c and probably others compilable
Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>