| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Merge upstream commit 4ce8afe6b. This has no effect on Windows.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Merge upstream commit 9f490785e. The changes are cosmetic, to
bring the code into line with dash.
|
|\| |
|
| |
| |
| |
| |
| |
| | |
Testsuite reports lots of message mismatches, fix that
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
o_save_ptr 176 167 -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
fetch_heredocs 477 485 +8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
glob_needed 71 86 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
generate_stream_from_string 222 232 +10
setup_heredoc 329 330 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 11/0) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
...and discover that we can do away with 1-3 initialization syscalls.
function old new delta
hush_main 1152 1146 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Also, make second calls to install_special_sighandlers() less haphazard.
It's not a fix for anything, but looking more organized now.
function old new delta
fflush_restore_ttypgrp_and__exit - 20 +20
restore_ttypgrp_and__exit 21 - -21
hush_main 1181 1152 -29
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 20/-50) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| | |
restore_ttypgrp_and_killsig_or__exit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
.rodata 105787 105823 +36
fetch_heredocs 461 477 +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The rationale here is that unsetting HISTFILE in /etc/profile
does not "stick": if it's unset, the default one is set later
(after /etc/profile is executed) by the shell.
But setting (and exporting, so it is inherited by all
(grand)child shells) an empty one works.
function old new delta
save_history 296 316 +20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
"HISTFILESIZE=0" in profile wasn't working as intended,
"unset HISTFILE" wasn't preventing creation of history files
Now:
HISTSIZE=n allows to reduce in-memory history buffer
HISTFILESIZE=n allows to reduce history file size (0: truncate it)
unset HISTFILE allows to not save history file at all
function old new delta
exitshell 138 194 +56
hush_exit 97 143 +46
save_history 266 296 +30
hush_main 1170 1186 +16
.rodata 105762 105771 +9
load_history 246 254 +8
size_from_HISTFILESIZE 44 41 -3
read_line_input 2746 2712 -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 165/-37) Total: 128 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
__ppoll_time64 - 211 +211
check_got_signal_and_poll - 164 +164
read_key 607 601 -6
shell_builtin_read 1328 1318 -10
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Make the read built-in more compatible with bash:
- Return an exit code of 142 on timeout.
- When the timeout expires before a newline is detected in the
input bash captures the partial input. This behaviour is new
since bash version 4.4. BusyBox shells had the pre-4.4 behaviour
where the input was lost.
Update the tests to suit and fix a couple of compiler errors in
the testsuite.
function old new delta
builtin_read 154 174 +20
readcmd 213 228 +15
shell_builtin_read 1364 1370 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0) Total: 41 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the '-n' option was used to limit the number of characters
read, any backslashes in the input weren't correctly accounted
for.
Adds 16 bytes.
(GitHub issue #504)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit e07a73a15 (ash: bring 'read' built-in closer to bash)
added code to treat a timeout differently from an error returned
by poll(2). This falsely assumed that only an EINTR error was
relevant. We must allow for other errors.
Adds 16 bytes.
(GitHub issue #502)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Consider this script:
#!/bin/sh -e
f() {
for n in $(seq 1 10); do
echo "Background $n ..."
sleep 1
done
}
f 1 &
f 2 &
f 3 &
wait
If this was interrupted by Ctrl+C the background jobs continued to
run. Avoid this by sending SIGINT to all children of the shell.
Saves 16 bytes.
(See GitHub PR #500)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 8e6991733 (ash: fix 'read' shell built-in (1)) noted
discrepancies between upstream BusyBox, busybox-w32 and bash.
It aligned busybox-w32 with upstream BusyBox. Apply further
changes in busybox-w32 to align 'read' more closely with bash.
- When a timeout occurs before a newline in the input stream,
capture and save the text collected so far.
- Return an exit code of 142 on timeout.
Also, since our implementation of poll(2) never sets errno to
EINTR the code to handle this case can be omitted.
Saves 16 bytes in the 64-bit build, adds 16 in 32-bit.
(GitHub issue #502)
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It seems that one of the workarounds for problems with stream i/o
in MSVCRT was unnecessary. It also caused display glitches when
the 32-bit binary was run on 64-bit systems.
Remove it.
Saves 112 bytes in the 32-bit build.
(GitHub issue #472)
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The previous commit failed to stop 'uname 1>&-' from writing to
standard output with 32-bit MSVCRT.
Close the stream _and_ the file descriptor.
(Github issue #472)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
These commands:
cut --wrong-opt 2>&1
echo $(cut --wrong-opt 2>&1)
resulted in different output. In the first case the message about
the invalid option appeared before the usage message; in the second
after.
The command
uname --wrong-opt 1>&- 2>&-
displayed the error message even though both output streams were
closed.
These issues appear to be related to those previously fixed by
commits 4be93f32f and f192e6539:
- They involve the interaction between shell redirection and stream
input/output.
- UCRT builds aren't affected.
Apply two workarounds:
- When the file descriptor associated with stderr is redirected
remind stderr it should be unbuffered. (32- and 64-bit MSVCRT)
- When the file descriptor associated with any of the standard i/o
streams is to be closed do it by closing the stream instead.
(32-bit MSVCRT)
Adds 48-176 bytes.
(GitHub commit #472)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The following has never worked properly in busybox-w32:
$ my_func() { return 5; }
$ my_func & sleep 1; wait $!; echo $?
The expected result is that 'echo' should display '5'. Actual
results used to be '0' and more recently have been '127'.
The culprit was commit fa6f44ea72 (win32: ash: reimplement
waitpid(-1)). When the status of a job changed its pid was set to
-1, which flagged processes of interest to the implementation of
waitpid().
This is no longer necessary as waitpid() now uses the process
handle instead. There's therefore no need to overwrite the pid.
(GitHub issue #470)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 633e3a5eae (ash: correctly identify applet in getopt() error
messages) made getopt() display the correct name for noexec applets
in case of error.
Do the same for nofork applets.
Adds 32-48 bytes.
|
| |
| |
| |
| | |
PPID is no longer fake.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This allows to simplify "which" applet code
function old new delta
find_executable 93 111 +18
which_main 191 177 -14
builtin_source 316 294 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-36) Total: -18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|