aboutsummaryrefslogtreecommitdiff
path: root/docs (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-04-21win32: export xappendword()Ron Yorston3-13/+13
The function xappendword() in make.c may have other uses. Export it.
2023-04-21su: escape quotes and backslashes in commandRon Yorston1-1/+1
In 'su -c "CMD"' CMD should become a single argument to busybox sh -c ... But previously, the parameter string to ShellExecute was constructed by placing the literal value of CMD inside double quotes, which could result in incorrect and/or more than one parameter seen by the program, because double-quotes and (some) backslashes in CMD should be escaped while constructing the string, but they weren't. Now they're escaped so that the WIN32 CommandLineToArgv[W] parses it into a single argument with value identical to the original CMD.
2023-04-19win32: case-sensitivity in tab completionRon Yorston3-44/+62
The tab-completion code treated all matches as case-insensitive because that's how Microsoft Windows handles filenames. This is now inadequate, as shell builtins, functions and aliases are case sensitive. Modify the treatment of case-sensitivity in tab completion: - Track whether each potential match is case-insensitive (filename) or case-sensitive (shell builtin, function or alias). - When comparing matches use a case-insensitive comparison if either value is a filename. Otherwise use a case-sensitive comparison. Adds 64 bytes.
2023-04-18dd: omit direct flagRon Yorston1-4/+19
O_DIRECT isn't supported with open(2) on Microsoft Windows. All code related to the 'direct' input/output flag can be omitted. Saves 160 bytes.
2023-04-16readlink: support --, -n alwaysEric Blake1-17/+12
POSIX will be standardizing readlink (just the -n option) and realpath (just -E and -e options): https://www.austingroupbugs.net/view.php?id=1457 Change things for readlink so that the POSIX-mandated -n and -- work even when disabling the non-standard (and partially non-working) -f when FEATURE_READLINK_FOLLOW is clear. POSIX also wants readlink to be verbose by default (if the argument is not a symlink, readlink must output a diagnostic); I did NOT address that one, because I'm waiting to see what the GNU Coreutils folks do: https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00035.html Partial fix for https://bugs.busybox.net/show_bug.cgi?id=15466 function old new delta packed_usage 34538 34557 +19 Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-16tr: display usage for incorrect argumentsRon Yorston1-1/+1
tr must have one or two non-option arguments. Display the usage message if any other number is present. function old new delta .rodata 108389 108392 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 3/0) Total: 3 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-16ash,hush: tab completion of functions and aliasesRon Yorston2-6/+40
Since commit 9e2a5668f (ash,hush: allow builtins to be tab-completed, closes 7532) ash and hush have supported tab completion of builtins. Other shells, bash and ksh for example, also support tab completion of functions and aliases. Add such support to ash and hush. function old new delta ash_command_name - 92 +92 hush_command_name - 63 +63 ash_builtin_name 17 - -17 hush_builtin_name 38 - -38 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 0/0 up/down: 169/-55) Total: 100 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Avi Halachmi <avihpit@yahoo.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-16wget: enable progress bar in default configurationRon Yorston3-3/+3
For some reason the progress bar in wget has never been enabled. Costs 1536-1600 bytes.
2023-04-16libbb: don't build useless functionsRon Yorston2-0/+8
The functions ndelay_on(), ndelay_off() and close_on_exec_on() don't do anything useful because our fcntl(2) implementation doesn't support the features they require. Replace them with stubs. Saves 176-208 bytes.
2023-04-16ash: more Unix-style path fixesRon Yorston1-7/+19
Commit 950b318a2 (ash: Unix-style paths, shell builtins and applets) broke running of Unix-style absolute paths from the shell by PATH search. The copy of the program name on the stack should only be used in the first call to tryexec() otherwise it interferes with the use of the stack by padvance(). Also, bring the code to handle Unix-style paths in find_command() into line with the revised code in shellexec().
2023-04-16win32: further fix incorrect path search in spawnvpRon Yorston1-1/+3
Commit 9581d2396 (win32: fix incorrect path search in spawnvp) fixed the unwanted PATH search for relative or absolute paths but broke the desired PATH search for Unix-style paths. (GitHub issue #310)
2023-04-14win32: fix incorrect path search in spawnvpRon Yorston1-3/+1
Commit 26ba73098e (win32: search PATH for missing Unix-style executables) rearranged the code of mingw_spawnvp(). As a result commands with a relative or absolute path could be incorrectly searched for on PATH. (GitHub issue #310)
2023-04-13hush: quote variable values printed by "set" (match ash behavior)Denys Vlasenko2-4/+19
function old new delta builtin_set 258 301 +43 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-13shuf: another tweak to COMMON_PREFIX_HACK codeDenys Vlasenko1-8/+4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12build system: clean more files on make cleanTomas Paukrt1-0/+1
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2023-04-12shuf: fix pfx_len calculationDenys Vlasenko1-1/+1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12shuf: remove redundant codeDenys Vlasenko1-2/+0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12shuf: add (disabled) code to support very long numbers in -i LO-HIDenys Vlasenko1-6/+58
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12lineedit: fix crash when icanon set with -echoAkos Somfai1-2/+2
When icanon is set with -echo (e.g. ssh from an emacs shell) then S.state will remain null but later it will be deferenced causing ash to crash. Fix: additional check on state. Signed-off-by: Akos Somfai <akos.somfai@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-12sleep: fix error exit when called as "sh" builtinDenys Vlasenko1-1/+2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-11seq: fix yet another case of negative parameters not workingDenys Vlasenko2-2/+7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-11seedrng: fix for glibc <= 2.24 not providing random headerThomas Devoogdt1-4/+10
- dropped the wrong define (not sure why it was there) - <sys/random.h> not available if glibc <= 2.24 - GRND_NONBLOCK not defined if <sys/random.h> not included - ret < 0 && errno == ENOSYS has to be true to get creditable set Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10seedrng: fix for glibc <= 2.24 not providing getrandom()Denys Vlasenko1-0/+14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10appletlib: fix "warning: unused variable applet_no"Tomas Paukrt1-1/+1
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10ash: fix sleep built-in not running INT trap immediately on ^CDenys Vlasenko1-9/+7
function old new delta sleep_for_duration 169 149 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10mkfs_vfat: do not generate same volume_id when run in rapid successionDenys Vlasenko1-2/+3
function old new delta mkfs_vfat_main 1502 1523 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-10seq: accept negative parametersDenys Vlasenko2-2/+24
function old new delta seq_main 429 476 +47 packed_usage 34557 34538 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 47/-19) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-09ash: remove ASH_IGNORE_CR config optionRon Yorston6-33/+10
No further problems with CRLF handling have been reported. Remove the configuration option that allowed some recent changes to be turned off. Also, prevent some WIN32 code from being included in the POSIX build. The faulty code is from commit 64c8f5f3d (ash: add support for INT trap). These changes don't alter the default WIN32 build.
2023-04-07xargs: kill children when interrupted by Ctrl-CRon Yorston1-3/+42
A user was running the following command in a clone of the busybox-w32 repo from a busybox-w32 shell using Git for Windows: git rev-list --all | xargs git grep main.c Using Ctrl-C to interrupt the command resulted in the familiar problem that two processes ended up competing for user input: in this case the busybox-w32 shell and the Git for Windows pager, less. Make the problem go away (in this particular case) by killing all the children of xargs when it's interrupted. This is probably a sensible thing to do for other circumstances too. Adds 64-100 bytes. (GitHub issue #306)
2023-04-06libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]Denys Vlasenko5-9/+8
function old new delta fork_or_rexec 46 56 +10 bootchartd_main 1087 1079 -8 cpio_main 674 661 -13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-05win32: ignore ctrl-c in parent of execve(2)Ron Yorston1-4/+14
The execve(2) system call is emulated for Microsoft Windows. This requires the creation of a new process. The old process remains active, waiting for the "execed" child to exit so it can pass on its exit status. Previously this was achieved using P_WAIT mode in the call to spawnve(). However the parent of the execve(2) process may still be able to catch Ctrl-C interrupts. This can lead to unwanted behaviour, such as a shell and its children competing for input. Force the waiting process to ignore Ctrl-C interrupts. Costs 64-80 bytes. (GitHub issue #303)
2023-04-05ash: special treatment for read builtinRon Yorston1-1/+4
When INT is being trapped the read builtin gets special treatment in bash. In a top-level interactive shell interrupting the read with Ctrl-C clears the input and allows the user to enter a new string. In a subshell Ctrl-C really does interrupt the read and the trap isn't executed. zsh works similarly, except that in the latter case the trap is executed. dash interrupts the read and executes the trap in both cases. ksh also interrupts the read in both cases but only executes the trap in the first. Implement the bash behaviour. (GitHub issue #303)
2023-04-05ash: reinstate fix for ctrl-c issueRon Yorston1-1/+1
Reinstate the change introduced in commit 96c104a61c (ash: try harder to avoid ctrl-c issue). It was removed during recent work on traps.
2023-04-03ash: sleep builtin with no arguments should not exitDenys Vlasenko2-2/+15
function old new delta sleep_main 116 143 +27 .rodata 105245 105268 +23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0) Total: 50 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03hush: printf builtin with no arguments should not exitDenys Vlasenko1-1/+1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: code shrink: do not take address of prefix(), allowing it to inlineDenys Vlasenko1-8/+4
function old new delta getjob 281 285 +4 prefix 13 - -13 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 4/-13) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: code shrink - reuse is_prefixed_with() from libbbDenys Vlasenko1-2/+4
function old new delta changepath 67 68 +1 legal_pathopt 70 66 -4 prefix 34 13 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-25) Total: -24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: get rid of separate mail_var_path_changed flag variableDenys Vlasenko1-10/+9
We can just clear mailtime_hash to zero and have the same effect. function old new delta changemail 8 11 +3 mail_var_path_changed 1 - -1 cmdloop 398 382 -16 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 3/-17) Total: -14 bytes text data bss dec hex filename 1054786 559 5020 1060365 102e0d busybox_old 1054773 559 5020 1060352 102e00 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: fix still-broken new mail detectionDenys Vlasenko1-4/+4
padvance() exit condition is return value < 0, not == 0. After MAIL changing twice, the logic erroneously concluded that "you have new mail". Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: fix broken new mail detectionDenys Vlasenko1-1/+0
Mea culpa, in "Do not allocate stack string in padvance" commit (I left an extraneous "break" statement). function old new delta cmdloop 329 398 +69 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-03ash: add support for INT trapRon Yorston3-10/+88
The trap builtin now handles INT. As before, other signals (from a limited list) are accepted but their traps don't have any effect. There's some variability in how shells handle traps. This patch upholds that proud tradition. Various changes are needed to make this work: - Line editing has a new flag to ignore Ctrl-C. - If INT is being trapped or ignored don't call raise_interrupt(). - A minimal implementation of dotrap() is provided. - Call dotrap() when the read builtin or line input detect Ctrl-C. - Adjust Ctrl-C detection when the INT trap is changed. - Set may_have_traps when an INT trap is set. Costs 368-448 bytes. (GitHub issue #303)
2023-04-03win32: add fake HUP and QUIT signalsRon Yorston2-2/+4
It's fairly common for shell scripts to trap this set of signals: EXIT HUP INT QUIT TERM (or the numeric equivalent: 0 1 2 3 15) Add definitions for SIGHUP and SIGQUIT. We don't take any action if traps are defined for them, but at least scripts won't fail. (GitHub issue #303)
2023-04-03ash: fix POSIX buildRon Yorston1-0/+2
Commit 950b318a2 (ash: Unix-style paths, shell builtins and applets) added a call to stack_add_ext_space() which should only be included when building for Microsoft Windows.
2023-04-01hush (NOMMU): fix LINENO in execed childrenDenys Vlasenko1-0/+15
function old new delta hush_main 1815 1851 +36 re_execute_shell 601 635 +34 .rodata 102721 102726 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 75/0) Total: 75 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-01hush: speed up "big heredoc" codeDenys Vlasenko1-7/+15
function old new delta hush_main 1810 1815 +5 .rodata 102723 102721 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-2) Total: 3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-01hush: add TODO commentDenys Vlasenko1-0/+3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-01ash: code shrinkDenys Vlasenko1-3/+3
function old new delta describe_command 323 320 -3 dotcmd 324 309 -15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-31ash: exec: Stricter pathopt parsing - lost chunkDenys Vlasenko1-1/+1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-31ash: improve trap and jobs builtins in child shellsRon Yorston3-6/+31
The trap and jobs builtins can be used to report information about traps and jobs. This works when they're called from the current shell but in a child shell the required information is usually cleared. Special hacks allow: - trap to work with command substitution; - jobs to work with command substitution or in a pipeline. Neither works with process substitution. - Relax the test for the trap hack so it also supports pipelines. - Pass the command to be evaluated to forkshell() in evalbackcmd() so trap and jobs both work with process substitution. function old new delta forkchild 629 640 +11 argstr 1502 1496 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 11/-6) Total: 5 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-31ash: Unix-style paths, shell builtins and appletsRon Yorston1-3/+6
Some shell builtins also exist as applets: echo, printf, pwd and test, for example. If such an applet is referenced using a Unix- style path, e.g. /usr/bin/echo, the applet should be run rather than the builtin. Instead the current code says: sh: /usr/bin/echo: file not found Rearrange the tests in shellexec() so the correct behaviour occurs. Actually, the error message was also incorrect due to a separate bug. Commit d71cb67ff (win32: revert special treatment of Unix-style absolute paths) failed to allocate space on the stack so that the command passed to tryexec() could have an extension added if required.