aboutsummaryrefslogtreecommitdiff
path: root/shell (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergemergeRon Yorston2024-12-301-0/+3
|\
| * 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>
* | ash: match behaviour of cmd.exe in cd builtinRon Yorston2024-11-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | win32: drop stream i/o workaroundRon Yorston2024-10-301-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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)
* | win32: try harder to prevent output to stdoutRon Yorston2024-10-291-1/+0
| | | | | | | | | | | | | | | | | | 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)
* | win32: more problems with stream i/o and MSVCRTRon Yorston2024-10-291-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | ash: fix waiting for status of background jobRon Yorston2024-10-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | ash: correctly identify nofork applets in error messageRon Yorston2024-10-281-0/+8
| | | | | | | | | | | | | | | | | | | | 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.
* | ash: update commentRon Yorston2024-10-131-1/+0
| | | | | | | | PPID is no longer fake.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-081-29/+57
|\|
| * libbb: modify find_executable() to not temporarily write to PATHDenys Vlasenko2024-10-081-21/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * hush: fix "type ./cat" and "command -v ./cat" to not scan PATHDenys Vlasenko2024-10-071-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta find_executable_in_PATH - 67 +67 if_command_vV_print_and_exit 114 116 +2 .rodata 105712 105710 -2 builtin_type 137 128 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 69/-11) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: make "test -x" use cached groupinfoDenys Vlasenko2024-10-071-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While at it, correct "type" to skip non-executable files in PATH function old new delta builtin_source 211 316 +105 builtin_test 10 32 +22 hush_main 1150 1170 +20 builtin_type 122 137 +15 if_command_vV_print_and_exit 120 114 -6 find_in_path 131 - -131 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 4/1 up/down: 162/-137) Total: 25 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-10-081-5/+51
|\|
| * ash: cache more of uid/gid syscallsDenys Vlasenko2024-10-071-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: setuidgid 1:1 strace ash -c 'test -x TODO; test -x TODO; echo $?' should show that second "test -x" does not query ids again. function old new delta ash_main 1236 1256 +20 get_cached_euid - 19 +19 get_cached_egid - 19 +19 test_main 56 72 +16 test_exec 119 135 +16 is_in_supplementary_groups 52 57 +5 nexpr 718 702 -16 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 95/-16) Total: 79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: make "test -x" use cached groupinfoDenys Vlasenko2024-10-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | function old new delta test_main2 - 407 +407 testcmd 10 23 +13 test_main 418 56 -362 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 420/-362) Total: 58 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: simplify parameter passing in is_in_supplementary_groups()Denys Vlasenko2024-10-071-5/+3
| | | | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups 54 52 -2 nexpr 721 718 -3 test_exec 125 119 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: command -v CMD must skip (go to next path) when CMD exists, but is not ↵Denys Vlasenko2024-10-071-3/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | executable Upstream commit: Date: Fri, 5 Apr 2024 17:55:46 +0800 exec: Check executable bit when searching path Andrej Shadura <andrew.shadura@collabora.co.uk> wrote: ... > https://bugs.debian.org/874264 > -------- Forwarded Message -------- > Subject: dash: 'command -v' mistakenly returns a shell script whose > executable is not set > Date: Mon, 04 Sep 2017 10:45:48 -0400 > From: Norman Ramsey <nr@cs.tufts.edu> > To: Debian Bug Tracking System <submit@bugs.debian.org> ... > I tracked a build bug in s-nail to a problem with dash. Symptom: > building s-nail tries to run /home/nr/bin/clang, a script whose > executable bit is not set. We tracked the problem to the result of > running `command -v clang` with /bin/sh: ... This is inherited from NetBSD. There is even a commented-out block of code that tried to fix this. Anyway, we now have faccessat so we can simply use it. function old new delta test_exec - 125 +125 find_command 911 918 +7 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 132/0) Total: 132 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: more changes to noexec appletsRon Yorston2024-10-071-30/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Change the 'flags' argument to shellexec()/tryexec() so it only indicates that it's permissible to run ash_main() directly. The flag is only set TRUE in forkshell_shellexec(). - The check for a script with an interpreter which is an applet is now performed for all calls to tryexec(), not just those that originate from evalcommand(). Saves 64-80 bytes. GitHub issue #461.
* | ash: fix regression with 'exec sh -s'Ron Yorston2024-10-061-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was noted this command didn't work properly: su -t -c 'exec sh -s -c "echo 123"' The child shell performed the 'echo' but then exited, despite the '-s' flag. This is a regression introduced by commit 074ebfca21 (ash: code shrink). This simpler command also failed the same way: sh -c "exec sh -s" This regression dates back even further, to commit da7c8cdf63 (ash: run ash_main() directly from a FS_SHELLEXEC shell). The issue can be avoided if shells invoked by the 'exec' builtin aren't run by calling ash_main() directly. Adds 80-96 bytes. GitHub issue #461.
* | Merge branch 'busybox' into mergeRon Yorston2024-09-282-48/+28
|\|
| * hush: whitespace and comment fixesDenys Vlasenko2024-09-281-43/+27
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: reject unknown long optionsRon Yorston2024-09-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 64f70cc755 (Add --login support) added code in options() to handle the bash-compatible '--login' option. In doing so it committed BusyBox ash to silently accepting all other long options. Restore compatibility with other ash variants by rejecting unknown long options. function old new delta options 589 624 +35 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: reject unknown long optionsRon Yorston2024-09-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Commit 64f70cc755 (Add --login support) added code in options() to handle the bash-compatible '--login' option. In doing so it committed BusyBox ash to silently accepting all other long options. Restore compatibility with other ash variants by rejecting unknown long options. (GitHub issue #457)
* | ash: code shrinkRon Yorston2024-09-081-6/+2
| | | | | | | | | | | | | | Allow ash_main() to be invoked directly even in a non-FS_SHELLEXEC shell. Saves 48-64 bytes.
* | ash: optimise running of scripts (2)Ron Yorston2024-09-041-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4b7b4a960 (ash: optimise running of scripts) avoided creation of a process when running a script. There's another case where we can do the same: if the script is being run from a FS_SHELLEXEC shell. - Check the necessary conditions for this to happen. - Allocate two extra slots in the argv array for FS_SHELLEXEC. - Set the index of the script file in the argv array. Without this the test 'pidof this' failed because the command name hadn't been correctly set. Adds 80-96 bytes.
* | ash: optimise running of scriptsRon Yorston2024-08-191-7/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BusyBox shell detects certain cases where forking a command is unnecessary (last command in a script or subshell, for example) and calls execve(2) instead. This doesn't help in the Windows port because execve(2) is implemented by creating a process. There is one case where it is possible to apply this optimisation: if the command is a script and the script interpreter is an applet. - Have evalcommand() pass a flag to indicate this situation to shellexec(). Also, allocate two spare elements before the start of the argv array. - If the flag is TRUE shellexec() passes the shell's PATH variable down to tryexec() so it can perform a test for applet override. - If tryexec() finds that all the necessary conditions apply it can run a script by directly invoking the interpreter's main(). Adds 192-224 bytes.
* | which,ash: code shrink detection of standalone shellRon Yorston2024-08-171-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 6d87be4d7 (which,ash: changes to which/command/type) let 'which' detect when it's run from a standalone shell by having the shell pass the undocumented '-s' option. A better solution is to alter argv[0] when 'which' is run from a standalone shell. This is possible because the code path through run_noexec_applet_and_exit() and which_main() doesn't actually use argv[0]. - No special treatment is required in ash when 'which' has no arguments or the '--help' option. - tryexec() no longer needs an extra element before the start of argv. The commit 027fb22e2 can be reverted and the allocation of argv in evalcommand() simplified. - 'which' no longer needs to handle the '-s' option. Saves 96-104 bytes.
* | ash: allow additional element in argv arrayRon Yorston2024-08-161-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tryexec() in ash relies on all callers of shellexec() having an additional unused element before the start of its argv array. In busybox-w32 this was not the case when shellexec() was called from forkshell_shellexec(), as only the actual contents of the argv array were copied into the forkshell data block. In practice argv[-1] is only currently used when the 'which' applet is about to be run, so whatever got overwritten (probably cmdtable[30]) was unlikely to matter. Still, let's be correct and allocate the additional element. Adds 16 bytes.
* | ash: rewrite waitpid_child() to improve performanceRon Yorston2024-07-301-32/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the previous commit there was still a slight disparity between shell performance with and without background jobs. Reduce this disparity by the following changes: - Remove the pidlist array. The PID of the exiting process can be obtained from its handle. - Save the proclist array between calls. It will always grow to support the required number of PIDs. - Combine the loops to compute the required size of proclist and to fill it. This saves a few bytes with no measurable impact on performance. Saves 8 bytes in a 32-bit build, adds 32 in 64-bit. (GitHub issue #434)
* | ash: fix slow running when background job is presentRon Yorston2024-07-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was noted that a simple 'while' loop would take considerably longer to run in a shell which had spawned a background job compared to one that hadn't. The problem originates with commit 4d8a277d59 (Implement nonblocking wait) which introduced a nonblocking wait in ash. This was found to cause the shell to use 100% of CPU when running 'sleep 60'. This was 'fixed' by commit 88b8cb61e (ash: Add a very small timeout to nonblocking wait). Subsequently commit 96c9c0044 (ash: allow waitpid_child to block) fixed a problem with the logic of the original commit, but it left the small timeout in place. It is this timeout which slows down the shell when a background job is present. The solution is to restore the 0 timeout for the nonblocking wait. Saves 0-16 bytes. (GitHub issue #434)
* | ash: ignore hidden/iconified stateRon Yorston2024-07-181-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some third-party terminal programs have a hidden console host to interact with console applications. When the busybox-w32 shell was used with such a terminal the hidden console host could be revealed because the shell expected it to be iconified. Since it doesn't much matter in this case whether the console host is hidden or iconified treat these states as equivalent. The user's preference set by the 'noiconify' option will still be respected when a console window is concealed. (GitHub issue #430)
* | Merge branch 'busybox' into mergeRon Yorston2024-07-141-12/+10
|\|
| * ash: move hashvar() calls into findvar()Ron Yorston2024-07-141-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dash has accepted a patch to remove the first argument of findvar(). It's commit e85e972 (var: move hashvar() calls into findvar()). Apply the same change to BusyBox ash. function old new delta findvar 35 40 +5 mklocal 268 261 -7 exportcmd 164 157 -7 setvareq 319 310 -9 lookupvar 150 141 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/4 up/down: 5/-32) Total: -27 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-07-1313-42/+119
|\|
| * hush: do not exit interactive shell on some redirection errorsDenys Vlasenko2024-07-137-18/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ echo >&99 hush: dup2(99,1): Bad file descriptor $ echo >&9999 hush: fcntl(1,F_DUPFD,10000): Invalid argument $ echo 2>/dev/tty 10>&9999 hush: fcntl(10,F_DUPFD,10000): Invalid argument $ still alive!_ function old new delta static.setup_redirects 334 394 +60 .rodata 105661 105712 +51 dup_CLOEXEC 49 79 +30 save_fd_on_redirect 263 277 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 155/0) Total: 155 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix "exec 3>FILE" aborting if 3 is exactly the next free fdDenys Vlasenko2024-07-138-7/+42
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: avoid duplicate fcntl(F_SETFD, FD_CLOEXEC) during initDenys Vlasenko2024-07-131-8/+3
| | | | | | | | | | | | | | function old new delta hush_main 1149 1150 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: remove limitation on fd# lengthDenys Vlasenko2024-07-121-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "echo text >&0000000000002" works as you would expect, "echo text >&9999999999" properly fails instead of creating a file named "9999999999". function old new delta expredir 219 232 +13 readtoken1 3045 3053 +8 parsefname 204 201 -3 isdigit_str9 45 - -45 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/1 up/down: 21/-48) Total: -27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: do not abort interactive mode on >&9999 redirectDenys Vlasenko2024-07-121-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With very large fd#, the error code path is different from one for closed but small fd#. Make it not abort if we are interactive: $ echo text >&99 # this wasn't buggy ash: dup2(9,1): Bad file descriptor $ echo text >&9999 # this was ash: fcntl(1,F_DUPFD,10000): Invalid argument function old new delta .rodata 105637 105661 +24 dup2_or_raise 35 38 +3 redirect 1084 1044 -40 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 27/-40) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2024-07-101-21/+12
|\|
| * ash: remove defunct control character to save a few bytesRon Yorston2024-07-101-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 549deab5a (ash: move parse-time quote flag detection to run-time) did away with the need to distinguish between backquotes inside and outside quotes. This left a gap among the control characters used in argument strings. Removing this gap saves a few bytes. function old new delta .rodata 167346 167338 -8 cmdputs 399 388 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix parsing of alias expansion + bash featuresRon Yorston2024-07-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An alias expansion immediately followed by '<' and a newline is parsed incorrectly: ~ $ alias x='echo yo' ~ $ x< yo ~ $ sh: syntax error: unexpected newline The echo is executed and an error is printed on the next command submission. In dash the echo isn't executed and the error is reported immediately: $ alias x='echo yo' $ x< dash: 3: Syntax error: newline unexpected $ The difference between BusyBox and dash is that BusyBox supports bash-style process substitution and output redirection. These require checking for '<(', '>(' and '&>' in readtoken1(). In the case above, when the end of the alias is found, the '<' and the following newline are both read to check for '<('. Since there's no match both characters are pushed back. The next input is obtained by reading the expansion of the alias. Once this string is exhausted the next call to __pgetc() calls preadbuffer() which pops the string, reverts to the previous input and recursively calls __pgetc(). This request is satisified from the pungetc buffer. But the first __pgetc() doesn't know this: it sees the character has come from preadbuffer() so it (incorrectly) updates the pungetc buffer. Resolve the issue by moving the code to pop the string and fetch the next character up from preadbuffer() into __pgetc(). function old new delta pgetc 28 589 +561 __pgetc 607 - -607 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 561/-607) Total: -46 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: restore value of imported variable on unexportRon Yorston2024-07-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shell variables imported from the environment are marked with a special flag and backslashes in their values are (by default) replaced with forward slashes. Sometimes this may not be what we want. Modify the 'export' shell built-in so unexporting a variable of this type restores its original value from the environment and removes its special flag. It can then be re-exported. Adds 32 bytes. (GitHub issue #428)
* | ash: read profile script relative to binaryRon Yorston2024-07-081-0/+4
| | | | | | | | | | | | | | As well as trying to read '/etc/profile' also look for the script 'etc/profile' relative to the location of the running binary. Adds 64-96 bytes.
* | win32: code shrink system drive handlingRon Yorston2024-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit (e3bfe3695) revised the use of getsysdir() to obtain the system directory, and hence the system drive. See the commit message for the history to that point. Further improvements are possible: - Remove getsysdir() and push the calls to GetSystemDirectory() down into get_system_drive() and get_proc_addr(). - Check the return value of GetSystemDirectory(). It's unlikely to fail, but better safe than sorry. - Instead of making all callers of get_system_drive() check for a NULL return value always return a non-NULL pointer. If the drive can't be found an empty string is returned instead (which is what the callers were using anyway). - The function need_system_drive() was only used in one place (in httpd). Move the code there and remove the function. - Use concat_path_file() where possible. Saves 76-144 bytes.
* | ash: special hack for libtoolRon Yorston2024-07-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | Libtool assumes the host environment is MSYS2 and will be confused by Windows-style command switches. The "/c" in "cmd /c" looks like a path, which MSYS2 incorrectly decodes to "c:/". Anticipating this, libtool encodes these calls as "cmd //c" which does not work outside MSYS2. A busybox-w32 patch makes it behave like MSYS2 in just this one case. Adds 88-96 bytes. (GitHub issue #297 and https://github.com/skeeto/w64devkit/issues/50)
* | win32: properly restore BB_ env varsRon Yorston2024-07-021-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some BB_ shell variables get special treatment: they're updated in the environment immediately on any change. One case was missed: if such a variable was unset or not exported and was overridden by a local variable it wasn't unset in the environment when the local variable went out of scope. Add the code required to do this. Adds 48-64 bytes. (GitHub issue #423)
* | Merge branch 'busybox' into mergeRon Yorston2024-06-2314-29/+85
|\|
| * ash: fix handling of single-quoted strings in pattern substitutionDenys Vlasenko2024-02-265-0/+29
| | | | | | | | | | | | | | function old new delta subevalvar 1576 1588 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>