aboutsummaryrefslogtreecommitdiff
path: root/coreutils/wc.c (unfollow)
Commit message (Collapse)AuthorFilesLines
27 hoursshells: add tests missing from last commitRon Yorston4-0/+30
29 hoursash: redir: Retry open on EINTRRon Yorston2-69/+93
Apply upstream commit 9b67dde8c. Adds 8 bytes in the 32-bit build.
2 daysash: eval: Reset handler when entering a subshellRon Yorston1-14/+33
Apply upstream commit 81274d8b3. On Windows it isn't necessary to reset the exception handler in evalbackcmd() or evalpipe(), as that will have been done by forkshell_init(). The globals_misc structure now contains a setjmp() buffer. On 64-bit Windows this needs 16-byte alignment. This is achieved in the forkshell data structure by placing the globals_misc data immediately after the 16-byte aligned forkshell data. Saves 144 bytes in the 64-bit build.
4 daysash: jobs: Block signals during tcsetpgrpRon Yorston1-1/+16
Merge upstream commit 4ce8afe6b. This has no effect on Windows.
4 daysash: eval: Add vfork supportRon Yorston4-36/+128
Merge upstream commit df154028d. Since we don't have vfork() on Windows we continue to use the spawn_forkshell() mechanism. Although there is some rearrangement of the code it's functionally the same.
4 daysash: rename got_sigchld, doing_jobctl, and INT_ON/OFF to match dashRon Yorston1-158/+158
Merge upstream commit 9f490785e. The changes are cosmetic, to bring the code into line with dash.
8 daysmake: override commands for single-colon target ruleRon Yorston1-7/+30
If more than one single-colon target rule has commands only the last set of commands should be used. Previously the presence of more than one single-colon target rule with commands was treated as an error. Adds 88-112 bytes.
2025-08-28tls: rewrite Schannel codeRFL8902-268/+283
The previous code had issues with buffer management, resulting in failures.
2025-08-26ls: add '-g' and '-C' to usage messageRon Yorston1-0/+5
For some reason upstream doesn't include the '-g' option in the usage message for 'ls'. Commit 551bfdb97 (ls: implement -q, fix -w0, reduce startup time) added a description but left it commented out. It didn't add 'g' to the list of options. 'C' appears in the list but its description is commented out. Adds 24-32 bytes. (GitHub issue #517)
2025-08-22lineedit: fix PS1='\W' for root directoryRon Yorston1-1/+1
An upstream bug caused '\W' to return an empty string for the root directory of any drive. bash displays '/' in similar circumstances on Linux. Adds 16 bytes. (GitHub issue #516)
2025-08-21tr: an escaped dash doesn't indicate a rangeRon Yorston2-0/+11
Upstream commit d683c5c2f1 (tr: support octal ranges) broke the previous behaviour that an escaped dash doesn't indicate a range: '[p\-r]' should match 'p', '-' or 'r', not 'p', 'q' or 'r'. Add a special case to handle this. Adds 16 bytes. (GitHub issue #515)
2025-08-18tls: various schannel fixesRFL8901-135/+61
2025-08-17win32: fix return value of isatty()Ron Yorston1-1/+1
Changes to the ls applet upstream assumed that the return value of isatty() followed the C standard and would be 0 or 1. The wrapper for Windows' _isatty() didn't allow for it returning a non-zero value for a tty, not 1. This confused ls. Fix the wrapper. (GitHub issue #513)
2025-08-12Use Windows API for checksums on ARM64Ron Yorston1-1/+1
The ARM64 build had native Windows support for TLS by default, but not checksums. Add this, so the ARM 64 build matches the Unicode build.
2025-08-12Post-merge fixesRon Yorston3-7/+88
Upstream has moved some functions from networking/tls.c to a new file, libbb/hash_hmac.c. The merge didn't adjust this code to allow it to work with the native Windows checksum API. This only matters if FEATURE_USE_CNG_API is enabled and CONFIG_FEATURE_TLS_SCHANNEL isn't. In that case the wget applet fails to handle https. None of the default configurations has this combination, but it should work. Make it so. The Windows code doesn't implement hmac_block(), as that's only used for password encryption which isn't currently supported. The variadic function hmac_peek_hash() isn't declared FAST_FUNC, as that causes clang to issue many warnings.
2025-08-10ash: move 100 bytes off global .data / .bss, no logic changesbusyboxDenys Vlasenko1-61/+62
text data bss dec hex filename 1067871 559 5184 1073614 1061ce busybox_old 1068067 555 5088 1073710 10622e busybox_unstripped ^^^^^^^^^^^ function old new delta pgetc 580 623 +43 parse_command 1633 1651 +18 ash_main 1226 1239 +13 popstring 115 126 +11 redirect 951 961 +10 popfile 105 115 +10 expandstr 252 262 +10 evalbltin 306 314 +8 pushstring 155 162 +7 pushfile 31 38 +7 freestrings 90 97 +7 setinputstring 68 74 +6 readtoken1 3095 3101 +6 pungetc 9 15 +6 nlprompt 39 45 +6 nlnoprompt 33 39 +6 unwindfiles 20 25 +5 dotcmd 309 314 +5 setinputfile 190 194 +4 init 429 432 +3 forkchild 617 620 +3 evalcommand 1616 1617 +1 ash_vmsg 141 142 +1 g_parsefile 4 - -4 commandname 4 - -4 basepf 84 - -84 ------------------------------------------------------------------------------ (add/remove: 0/3 grow/shrink: 23/0 up/down: 196/-92) Total: 104 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-10tls: only show schannel config option on mingwrfl8901-1/+1
2025-08-09ash: redir: Retry open on EINTRDenys Vlasenko5-67/+119
Upstream commit: Date: Thu, 28 May 2020 21:31:45 +1000 redir: Retry open64 on EINTR It is possible for open64 to block on named pipes, and therefore it can be interrupted by signals and return EINTR. We should only let it fail with EINTR if real signals are pending (i.e., it should not fail on SIGCHLD if SIGCHLD has not been trapped). This patch adds a new helper sh_open to retry the open64 call if necessary. It also calls sh_error when appropriate. Fixes: 3800d4934391 ("[JOBS] Fix dowait signal race") Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: eval: Reset handler when entering a subshellDenys Vlasenko1-3/+16
Upstream commit: Date: Sun, 3 Mar 2019 21:57:50 +0800 eval: Reset handler when entering a subshell As it is a subshell can execute code that is only meant for the parent shell when it executes a longjmp that is caught by something like evalcommand. This patch fixes it by resetting the handler when entering a subshell. function old new delta evalsubshell 169 183 +14 evalpipe 342 356 +14 argstr 1406 1416 +10 ash_main 1236 1226 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 65/-10) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ahs: jobs: Block signals during tcsetpgrpDenys Vlasenko1-1/+16
Upstream commit: Date: Wed, 6 Jan 2021 15:45:12 +1100 jobs: Block signals during tcsetpgrp Harald van Dijk <harald@gigawatt.nl> wrote: > On 19/12/2020 22:21, Steffen Nurpmeso wrote: >> Steffen Nurpmeso wrote in >> <20201219172838.1B-WB%steffen@sdaoden.eu>: >> |Long story short, after falsely accusing BSD make of not working >> >> After dinner i shortened it a bit more, and attach it again, ok? >> It is terrible, but now less redundant than before. >> Sorry for being so terse, that problem crosses my head for about >> a week, and i was totally mislead and if you bang your head >> against the wall so many hours bugs or misbehaviours in a handful >> of other programs is not the expected outcome. > > I think a minimal test case is simply > > all: > $(SHELL) -c 'trap "echo TTOU" TTOU; set -m; echo all good' > > unless I accidentally oversimplified. > > The SIGTTOU is caused by setjobctl's xtcsetpgrp(fd, pgrp) call to make > its newly started process group the foreground process group when job > control is enabled, where xtcsetpgrp is a wrapper for tcsetpgrp. (That's > in dash, the other variants may have some small differences.) tcsetpgrp > has this little bit in its specification: > > Attempts to use tcsetpgrp() from a process which is a member of > a background process group on a fildes associated with its con‐ > trolling terminal shall cause the process group to be sent a > SIGTTOU signal. If the calling thread is blocking SIGTTOU sig‐ > nals or the process is ignoring SIGTTOU signals, the process > shall be allowed to perform the operation, and no signal is > sent. > > Ordinarily, when job control is enabled, SIGTTOU is ignored. However, > when a trap action is specified for SIGTTOU, the signal is not ignored, > and there is no blocking in place either, so the tcsetpgrp() call is not > allowed. > > The lowest impact change to make here, the one that otherwise preserves > the existing shell behaviour, is to block signals before calling > tcsetpgrp and unblocking them afterwards. This ensures SIGTTOU does not > get raised here, but also ensures that if SIGTTOU is sent to the shell > for another reason, there is no window where it gets silently ignored. > > Another way to fix this is by not trying to make the shell start a new > process group, or at least not make it the foreground process group. > Most other shells appear to not try to do this. This patch implements the blocking of SIGTTOU (and everything else) while we call tcsetpgrp. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: eval: Add vfork supportDenys Vlasenko4-37/+117
Upstream commit: Date: Sat, 19 May 2018 02:39:56 +0800 eval: Add vfork support This patch adds basic vfork support for the case of a simple command. Upstream commit: Date: Tue, 12 Jan 2021 17:11:19 +1100 jobs: Always reset SIGINT/SIGQUIT handlers On Fri, Jan 08, 2021 at 08:55:41PM +0000, Harald van Dijk wrote: > On 18/05/2018 19:39, Herbert Xu wrote: > > This patch adds basic vfork support for the case of a simple command. > > ... @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *n, int > > mode) > > } > > } > > if (!oldlvl && iflag) { > > - setsignal(SIGINT); > > - setsignal(SIGQUIT); > > + if (mode != FORK_BG) { > > + setsignal(SIGINT); > > + setsignal(SIGQUIT); > > + } > > setsignal(SIGTERM); > > } > > + > > + if (lvforked) > > + return; > > + > > for (jp = curjob; jp; jp = jp->prev_job) > > freejob(jp); > > } > > This leaves SIGQUIT ignored in background jobs in interactive shells. > > ENV= dash -ic 'dash -c "kill -QUIT \$\$; echo huh" & wait' > > As of dash 0.5.11, this prints "huh". Before, the subprocess process killed > itself before it could print anything. Other shells do not leave SIGQUIT > ignored. > > (In a few other shells, this also prints "huh", but in those other shells, > that is because the inner shell chooses to ignore SIGQUIT, not because the > outer shell leaves it ignored.) Thanks for catching this. I have no idea how that got in there and it makes no sense whatsoever. This patch removes the if conditional. Fixes: e94a964e7dd0 ("eval: Add vfork support") Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: rename got_sigchld, doing_jobctl, and INT_ON/OFF to match dashDenys Vlasenko1-150/+150
Comparing code with dash is more difficult with these differences. (We didn't know back then that dash will be revived...) Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: fix fallout of no-more-set commandnameDenys Vlasenko1-6/+7
Testsuite reports lots of message mismatches, fix that Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09shells: fix a typo in var_backslash1.tests, expand it while at itDenys Vlasenko4-8/+12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: eval: Always set exitstatus in evaltreeDenys Vlasenko1-6/+7
Upstream commit: Date: Tue, 6 Dec 2022 16:49:14 +0800 eval: Always set exitstatus in evaltree There is no harm in setting exitstatus unconditionally in evaltree. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: options: Do not set commandname in procargsDenys Vlasenko1-3/+2
Upstream commit: Date: Mon Feb 25 12:49:20 2019 +0800 options: Do not set commandname in procargs We set commandname in procargs when we don't have to. This results in a duplicated output of arg0 when an error occurs. function old new delta ash_main 1256 1236 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09ash: jobs: drop unused node parameter in makejob()Denys Vlasenko1-6/+6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-09shells: add testsuite itemDenys Vlasenko4-0/+124
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-08ash: reuse vstype_suffix[] in debug code, shrink itDenys Vlasenko1-35/+37
function old new delta vstype_suffix - 39 +39 static.vstype 42 - -42 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/0 up/down: 39/-42) Total: -3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-08tls: change build defaultsRon Yorston4-4/+16
Update the default build configurations to enable the native TLS library in the 64-bit Unicode and ARM64 builds.
2025-08-08tls: whitespace fixesRon Yorston5-8/+8
No functional changes.
2025-08-08tls: fix schannel handshake on older WindowsRFL8901-1/+1
2025-08-07ash: fix cmdputs - was showing some variable forms incorrectlyDenys Vlasenko1-20/+35
function old new delta cmdputs 402 418 +16 static.vstype 48 42 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 16/-6) Total: 10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-07stty: fix build for Windows XPRon Yorston1-0/+10
The ioctl() to get the size of the terminal windows used functions which weren't available on Windows XP. Load these dynamically to avoid failure. Adds 160 bytes.
2025-08-07tls: add Schannel implementationrfl8906-14/+635
Not enabled by default. When enabled without TLS 1.3 support, saves 16784-18776 bytes. (GitHub PR #510)
2025-08-07hush: smarter optimization for not-globbing [ and [[Denys Vlasenko1-37/+23
function old new delta o_save_ptr 176 167 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-07ash: fix heredoc.tests broken by last commitDenys Vlasenko1-15/+19
function old new delta readtoken1 3053 3095 +42 xxreadtoken 215 212 -3 expandstr 255 252 -3 parseheredoc 148 127 -21 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 42/-27) Total: 15 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-07ash,hush: fix corner cases with backslash-newlines in heredocsDenys Vlasenko14-5/+44
function old new delta fetch_heredocs 477 485 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-07hush: optimization: do not glob words "[" and "[["Denys Vlasenko1-0/+40
function old new delta glob_needed 71 86 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06showkey: make -a, -k, -s mutually exclusiveDenys Vlasenko1-2/+2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06top,pmap: speed up /smaps parsingDenys Vlasenko3-24/+49
function old new delta procps_read_smaps 515 529 +14 procps_get_maps 685 665 -20 .rodata 105847 105820 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 14/-47) Total: -33 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06libbb: fix too-narrow variable in procps_read_smaps() causing incorrect sizesDenys Vlasenko1-1/+1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06libbb: make read_cmdline() replace chars 1..31 with '?', not spaceDenys Vlasenko2-7/+11
Space was too inconspicuous on output Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06top: simplify command line readingDenys Vlasenko2-18/+26
function old new delta cmdline_to_line_buf_and_print - 48 +48 read_cmdline 326 327 +1 display_topmem_process_list 523 505 -18 display_process_list 1186 1161 -25 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 49/-43) Total: 6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-06top: disentangle printing logicDenys Vlasenko1-83/+97
function old new delta print_line_buf - 78 +78 print_line_bold - 50 +50 top_main 1043 1091 +48 handle_input 708 714 +6 do_stats 186 192 +6 .rodata 115543 115526 -17 display_topmem_process_list 748 523 -225 display_process_list 1432 1186 -246 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/3 up/down: 188/-488) Total: -300 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05top: consistently NOT use the last column of the displayDenys Vlasenko1-56/+51
function old new delta .rodata 115537 115543 +6 top_main 1047 1043 -4 display_process_list 1459 1432 -27 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 6/-31) Total: -25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05pmap: increase max handled command line length to 4kDenys Vlasenko1-5/+7
function old new delta procps_get_maps 181 779 +598 read_smaps 563 - -563 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 598/-563) Total: 35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05top,pmap: do not use common code for reading /proc/PID/smapsDenys Vlasenko4-131/+178
The logic is in fact quite far from common. While at it, stop accounting "---p" mappings as mapped (e.g. VSZ in top). Nothing is mapped there (why would kernel waste RAM to map pages which can't be accessed?). function old new delta read_smaps - 562 +562 read_cmdline 315 326 +11 print_smaprec 97 101 +4 procps_scan 1219 1211 -8 .rodata 115541 115533 -8 skip_whitespace_if_prefixed_with 25 - -25 procps_read_smaps 864 577 -287 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 2/3 up/down: 577/-328) Total: 249 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05top: improve response time to keyboard inputDenys Vlasenko1-14/+27
function old new delta handle_input 674 708 +34 top_main 1019 1047 +28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 62/0) Total: 62 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-08-05top: reduce flicker: redraw screen with "clear to EOL" commands, not one ↵Denys Vlasenko1-14/+20
"clear screen" function old new delta display_topmem_process_list 680 748 +68 display_process_list 1403 1459 +56 .rodata 115512 115541 +29 top_main 1014 1019 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 158/0) Total: 158 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>