aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* win32: enhanced support for SIGPIPEHEADFRP-5579-g5749feb35masterRon Yorston2025-02-081-4/+0
| | | | | | | | | | | | | | | | Commit 68ddd4ec3c (win32: emulate SIGPIPE) allowed broken pipes to be detected so that processes could either return EPIPE or terminate. Later, commit 1b2ee3667 (win32: add fake HUP and QUIT signals) added support for two additional fake signals, thus allowing the 'kill' applet to refer to them by name and the shell to define (though not execute) traps for them. Add PIPE to the list of signals known to 'kill' and the shell, though still without support for calling the trap function. (GitHub issue #482)
* win32: retry when command needs elevated privilegesRon Yorston2025-02-034-12/+71
| | | | | | | | | | | | | | Some installer programs have an entry in their manifest to indicate that they need elevated privileges. The shell in busybox-w32 was unable to run such programs. When a program fails to run with ERROR_ELEVATION_REQUIRED, try again using ShellExecuteEx() with the 'runas' verb to give it elevated privileges. Adds 272-288 bytes. (GitHub issue #481)
* make: fix detection of target rule with inline commandRon Yorston2025-01-221-2/+16
| | | | | | | | | | | | | | | | Commit f9d10b2b6 (make: fix detection of target rules (take 2)) added code to handle the case where a target rule had an inline command with a ';' separator in a macro. This required all macros on the line to be expanded, including those in the inline command. The ';' should first be searched for in the original line (without any macro expansion) and only if that fails should macros be expanded. This matches the behaviour of GNU and Unix V7 make. BSD and Schily make don't handle the case where the ';' is in a macro. (pdpmake GitHub issue 73)
* make: fix single-suffix inference rule regressionRon Yorston2025-01-212-3/+24
| | | | | | | | | | | | Commit 85bbce87d (make: support GNU/BSD suffixes and inference rules) added code to handle inference rules with arbitrary suffixes. Unfortunately it failed to check for a single-suffix rule in the case where no known suffix was found. Add the necessary code and a test which would have caught the problem. Adds 48 bytes. (pdpmake GitHub issue 72)
* make: phony targets and double colon rulesRon Yorston2025-01-161-7/+12
| | | | | | | | | | | | | | | | | | | Commit 770bad1fe (make: disallow inference rules for phony targets) added the GNU/BSD make feature that inference rules aren't used for phony targets. Normally a double-colon rule without associated commands causes an inference rule search. If the target of the double-colon rule was phony no search was carried out and the rule failed. As a result of this perl failed to build (on Linux, I didn't try on Windows). When a double-colon rule has no commands and a phony target the prerequisites should be built and the rule should succeed. Adds 32 bytes. (pdpmake GitHub issue #70)
* make: minor tweaksRon Yorston2025-01-161-32/+37
| | | | | | | | | | | Move the code to remove the suffix from a target into a separate function. There's no need to test for non-NULL 'makefile' in newcmd(). Cosmetic changes. Saves 0-16 bytes.
* make: support GNU/BSD suffixes and inference rulesRon Yorston2025-01-143-71/+224
| | | | | | | | | | | | | | The specification of inference rules in POSIX implies that only suffixes starting with a period and containing no other periods are to be considered. In contrast, both GNU and BSD make allow suffixes to contain an arbitrary number of periods, or none at all. Allow this as an extension. Adds 640-816 bytes. (pdpmake GitHub issue 70)
* win32: fix compilation with FEATURE_SH_NOFORK disabledRon Yorston2024-12-312-3/+5
| | | | | Compiling with FEATURE_SH_NOFORK disabled resulted in an error and a warning. Fixing these doesn't change the default build.
* Merge branch 'busybox' into mergemergeRon Yorston2024-12-307-208/+422
|\
| * cut: code shrinkbusyboxDenys Vlasenko2024-12-211-6/+5
| | | | | | | | | | | | | | | | | | move "linenum" manipulations to the one place where it is used. function old new delta cut_main 1373 1360 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: code shrinkDenys Vlasenko2024-12-211-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | This change eliminates one temporary: - if (dcount++ < cut_list[cl_pos].startpos) + dcount++; + if (dcount <= cut_list[cl_pos].startpos) function old new delta cut_main 1402 1373 -29 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix up -D/-s behavior with -FDenys Vlasenko2024-12-202-5/+36
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1388 1402 +14 packed_usage 34934 34933 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-1) Total: 13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: remove unnecessary initialization of regmatch_tDenys Vlasenko2024-12-201-1/+1
| | | | | | | | | | | | | | function old new delta cut_main 1404 1388 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: shorten error messages on bad syntax even moreDenys Vlasenko2024-12-161-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ cut -s -b3 cut: -s requires -f or -F $ cut -d@ -b3 cut: -d DELIM requires -f or -F function old new delta static.requires_f - 19 +19 static._op_on_field 32 - -32 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/0 up/down: 19/-32) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: shorten error messages on bad syntaxDenys Vlasenko2024-12-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to mimic GNU cut error messages. $ cut -d@ -b3 cut: -d DELIM makes sense only with -f or -F $ cut -s -b3 cut: -s makes sense only with -f or -F function old new delta static._op_on_field 31 32 +1 .rodata 105659 105598 -61 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-61) Total: -60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: terminate cut_list[] so that we don't need "size of the array" variableDenys Vlasenko2024-12-161-20/+25
| | | | | | | | | | | | | | function old new delta cut_main 1410 1404 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: we can't get empty cut_list[], remove the check for thatDenys Vlasenko2024-12-161-8/+11
| | | | | | | | | | | | | | function old new delta .rodata 105685 105659 -26 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: disallow -f '' and -f '-'Denys Vlasenko2024-12-151-15/+19
| | | | | | | | | | | | | | function old new delta cut_main 1391 1410 +19 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix -F n-m to match toyboxDenys Vlasenko2024-12-142-3/+28
| | | | | | | | | | | | | | function old new delta cut_main 1339 1391 +52 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: simplify getopt32 codeDenys Vlasenko2024-12-131-11/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: "it's legal to pass an empty list" seems to be untrueDenys Vlasenko2024-12-131-46/+44
| | | | | | | | | | | | | | function old new delta cut_main 1344 1339 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: whitespace fixesDenys Vlasenko2024-12-131-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: tweak commentsDenys Vlasenko2024-12-131-3/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix handling of -d ''Denys Vlasenko2024-12-132-1/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: prevent infinite loop if -F REGEX matches empty delimiterDenys Vlasenko2024-12-131-1/+3
| | | | | | | | | | | | | | function old new delta cut_main 1339 1348 +9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: tweak --helpDenys Vlasenko2024-12-112-11/+10
| | | | | | | | | | | | | | | | | | | | | | function old new delta packed_usage 34901 34934 +33 cut_main 1353 1339 -14 .rodata 105724 105685 -39 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 33/-53) Total: -20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix -d$'\n' --output-delimiter=@@ behaviorDenys Vlasenko2024-12-102-7/+53
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1261 1353 +92 packed_usage 34925 34901 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 92/-24) Total: 68 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: implement --output-delimiterDenys Vlasenko2024-12-102-10/+49
| | | | | | | | | | | | | | | | | | | | function old new delta cut_main 1204 1261 +57 static.cut_longopts - 20 +20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: with -F disabled in .config, don't show it in --helpDenys Vlasenko2024-12-101-5/+13
| | | | | | | | | | | | | | function old new delta packed_usage 34897 34849 -48 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: comment out code which seems to be not neededDenys Vlasenko2024-12-101-7/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix "echo 1.2 | cut -d. -f1,3" (print "1", not "1.")Denys Vlasenko2024-12-102-7/+27
| | | | | | | | | | | | | | function old new delta cut_main 1228 1201 -27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: with -F, do not regcomp() pattern for every fileDenys Vlasenko2024-12-101-18/+24
| | | | | | | | | | | | | | function old new delta cut_main 1218 1228 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: rename "cut_lists" to "cut_list"Denys Vlasenko2024-12-101-19/+20
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: rename some variables to hopefully better namesDenys Vlasenko2024-12-101-13/+19
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: "orig_line" is redundant, remove itDenys Vlasenko2024-12-101-2/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: allocate "printed" only if OPT_CHAR or OPT_BYTEDenys Vlasenko2024-12-101-3/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: localize 'spos' variable, convert !NUMVAR to NUMVAR == 0Denys Vlasenko2024-12-101-5/+6
| | | | | | | | | | | | This imporves readability Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: simplify OPT_ names, eliminate one variableDenys Vlasenko2024-12-101-24/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: improve detection of invalid rangesRon Yorston2024-12-102-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0068ce2fa (cut: add toybox-compatible options -O OUTSEP, -D, -F LIST) added detection of reversed ranges. Further improvements are possible. - The test for reversed ranges compared the start after it had been decremented with the end before decrement. It thus missed ranges of the form 2-1. - Zero isn't a valid start value for a range. (Nor is it a valid end value, but that's caught by the test for a reversed range.) - The code if (!*ltok) e = INT_MAX; duplicates a check that's already been made. - Display the actual range in the error message to make it easier to find which range was at fault. function old new delta .rodata 100273 100287 +14 cut_main 1239 1237 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-2) Total: 12 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: fix "-s" flag to omit blank linesColin McAllister2024-12-102-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using cut with the delimiter flag ("-d") with the "-s" flag to only output lines containing the delimiter will print blank lines. This is deviant behavior from cut provided by GNU Coreutils. Blank lines should be omitted if "-s" is used with "-d". This change introduces a somewhat naiive, yet efficient solution, where line length is checked before looping though bytes. If line length is zero and the "-s" flag is used, the code will jump to parsing the next line to avoid printing a newline character. function old new delta cut_main 1196 1185 -11 Signed-off-by: Colin McAllister <colinmca242@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hexdump: fix regression with -n4 -e '"%u"'Natanael Copa2024-12-092-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug introduced in busybox 1.37.0 that broke kernel builds. Fixes commit e2287f99fe6f (od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -s) function old new delta rewrite 967 976 +9 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: tidy argument checks in getopt32()Ron Yorston2024-12-091-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When getopt32() has complementary options it's possible to specify the minimum and maximum number of arguments allowed. Checking these values was inconsistent: - '?' correctly checked that it was followed by a digit but set the otherwise unused spec_flgs variable on error. - '=' failed to check that it was followed by a digit. function old new delta vgetopt32 1307 1319 +12 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * chpst: fix error check of nice(2) callChristian Franke2024-12-091-1/+2
| | | | | | | | | | | | | | | | Check errno instead of return value because -1 is a valid return value also on success. Signed-off-by: Christian Franke <christian.franke@t-online.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix G.argv0_for_re_execing to avoid endless loopHajime Tazaki2024-12-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the busybox is used as /sbin/init and the inittab file contains below: ::respawn:-/bin/sh /sbin/init spawns hush for the first time with the argv[0] contains '-', and hush treats it as login shell. Then it reads /etc/profile and if the file contains the command execution like below, it invokes hush as login shell because the argv[0] argument is still '-/bin/sh' and reads /etc/profile again. This will last until some failure (e.g., memory failure) happens. [ "$(id -u)" -eq 0 ] && PS1="${PS1}# " || PS1="${PS1}\$ " This commit fixes this issues by adding an offset (+1) to the G.argv0_for_re_execing variable. This issue happens on our out-of-tree UML (use mode linux) with nommu configuration. Link: https://lore.kernel.org/all/cover.1731290567.git.thehajime@gmail.com/ Signed-off-by: Hajime Tazaki <thehajime@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | xargs: allow for quotes in commands on WindowsRon Yorston2024-12-301-2/+103
| | | | | | | | | | | | | | | | | | | | | | When xargs limited the length of the command lines it generated it didn't allow for the quoting Windows spawn() introduces. Properly account for any additional characters required when a command is spawned on Windows. If the command is a NOFORK applet this isn't necessary. Adds 384-464 bytes.
* | win32: code shrink quote_arg()Ron Yorston2024-12-301-24/+20
| | | | | | | | | | | | | | | | Alter quote_arg() to perform a single pass over the string in the case where no change is required. Based on a proposal by @avih in GitHub PR #317. Saves 16 bytes.
* | ash: strip trailing slash from directory if necessaryRon Yorston2024-12-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | The previous commit removed trailing dots and spaces from the last component of a pathname when changing directory. If the result has a trailing slash remove that too. But not if it's a drive root, to avoid 'cd C:/' showing a current directory of 'C:'. Adds 48 bytes. (GitHub issue #478)
* | ash: match behaviour of cmd.exe in cd builtinRon Yorston2024-11-193-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The Windows API strips trailing dots and spaces from the last component of a path. cmd.exe handles this quirk when changing directory by adjusting its idea of the current directory to match reality. The shell in busybox-w32 didn't do this, leading to some confusion. Fix the shell's cd builtin so it works more like cmd.exe. Adds 64-80 bytes. (GitHub issue #478)
* | tar: try harder to detect old tar filesRon Yorston2024-11-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code to autodetect compressed tar files failed to detect a bunzip2-compressed archive. When tar was invoked with the 'j' option it worked fine. The autodetection code looks for the magic string 'ustar' or a series of five NULs to determine that an archive is uncompressed. The failing archives had more than five NULs in the header and were taken to be uncompressed. Look for a longer run of NULs: 16 is certainly sufficient for the archives in question. Adds 8-16 bytes. (GitHub issue #475)
* | nproc: remove old codeRon Yorston2024-11-071-3/+1
| | | | | | | | | | | | | | | | | | Upstream commit 5a68a246e (nproc: prepare for arbitrarily large CPU masks) dynamically allocated the 'masks' array. When this was merged into busybox-w32 the old code was inadvertantly left in place. Remove it now. This has no effect on Windows builds.