aboutsummaryrefslogtreecommitdiff
path: root/archival (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-05-31make: fix detection of target rules (take 2)Ron Yorston2-184/+177
Commit d6b764116 (make: fix detection of target rules) checked for target rules before macro assignments. This failed for some Makefiles generated by autotools because partially defined macros were expanded while testing for a target rule. Revert to checking for macro assignments first, but try to detect if the proposed left hand side of the assignment might form part of a target rule with an inline command. Also handle the case where the ';' separator of the inline command has been obfuscated by putting it in a macro. Saves 128-160 bytes. (GitHub pdpmake issues 31, 44)
2024-05-29make: allow :::= macro assignment on command lineRon Yorston2-16/+52
GNU make and bmake have different implementations for := macro assignment. In POSIX 202X these are supported by the forms ::= and :::= respectively. Only the former was supported on the pdpmake command line. Add the required support in process_macros() and update the usage message. Adds 48-64 bytes.
2024-05-29make: relax the test 'Return error if command fails'Ron Yorston1-1/+1
The test 'Return error if command fails' needed an exit code of 2. POSIX only requires an exit code greater than 0.
2024-05-28make: fixes to -q optionRon Yorston2-36/+43
The -q option returns an exit status to indicate if targets are up-to-date (0) or in need of updating (1) but without updating them. As an exception (imported from GNU make) build commands with a '+' prefix are executed. pdpmake didn't implement the exception. Doing so required moving handling of the -q option down into docmds(). Saves 48 bytes.
2024-05-28make: fixes to -t optionRon Yorston2-33/+60
The -t option (in general) causes targets to be touched instead of having build commands run to create them. There were two problems. The flag variable 'ssilent' in docmds was too small (uint8_t) to contain the value of 'dotouch' (uint32_t). Truncation of the value resulted in build commands being echoed when they shouldn't have been. The POSIX specification is unclear as to how build commands with a '+' prefix interact with touch. The rationale indicates that this feature was imported from GNU make, so the behaviour has been made to match what it does: if a '+' build command is run the target is not touched. The code has been rearranged to move the call to touch() up into docmds(). Adds 48 bytes.
2024-05-27make: improved support for POSIX levelsRon Yorston5-5/+37
The default POSIX level to be enforced in strict mode is now a configuration option. Print details of supported POSIX levels in the usage message. Adds 56-64 bytes.
2024-05-25make: add posix_2017 pragmaRon Yorston1-9/+40
The pragma 'posix_202x' causes the 202X POSIX standard to be enforced in POSIX mode. Add an equivalent 'posix_2017' for the 2017 standard. There's now a DEFAULT_POSIX_LEVEL preprocessor symbol to configure the default standard. This is hardcoded to the 2017 standard but it can also be set to 202X. Adds 48 bytes.
2024-05-24make: fix tests for BSDRon Yorston1-4/+4
A couple of tests require backslashes to be escaped. The test for CURDIR should use 'pwd -P' to resolve symlinks.
2024-05-22make: add support for ifeq/ifneqRon Yorston2-16/+96
Add support for the conditional directives ifeq and ifneq. These follow GNU make in allowing things like: ifeq (arg1,arg2) ifeq 'arg1' 'arg2' In the second case single or double quotes may be used. Macros are expanded in the two arguments and the resulting strings are compared. Adds 240-248 bytes.
2024-05-22make: set $< and $* for target rulesRon Yorston2-6/+40
POSIX only requires $< and $* to be set for inference rules, not target rules. As an extension allow them to be set for target rules, as in GNU make. This may or may not be useful. In POSIX mode, when $< and $* are only set for inference rules, they're set to an empty string for target rules. This avoids the possibility of stale values being used. Adds 64-80 bytes. (GitHub issue #407)
2024-05-22make: add support for CURDIR macroRon Yorston2-5/+53
Austin Group defect report 1626 introduced support for the CURDIR macro: https://www.austingroupbugs.net/view.php?id=1626 Implement this as a POSIX 202X feature. Adds 160-176 bytes.
2024-05-22ash: fix commentRon Yorston1-1/+1
2024-05-21ash: prevent mintty from setting HOMERon Yorston1-1/+13
The Cygwin terminal program mintty sets the HOME environment variable. Attempt to detect this and unset HOME so the usual busybox-w32 initialisation of HOME is used instead. Adds 80 bytes. (GitHub issue #420)
2024-05-18win32: some changes to kill(2)Ron Yorston1-26/+27
Merge the kill() and kill_pids() functions. Allocate an array for the PIDs rather than use a hardcoded one. Adds 32 bytes to the 32-bit build, none to 64-bit.
2024-05-16win32: implement getppid(2)Ron Yorston2-10/+25
busybox-w32 had a dummy implementation of getppid(2) which always returned 1. Provide a more realistic version. The effect is limited: - The PPID shell variable should report a sensible value. - The special value to omit the parent PID 'pidof -o %PPID' should work. Costs 48 bytes.
2024-05-16win32: ensure PIDs are read early in procps_scan()Ron Yorston2-12/+16
Recent changes to allow orphaned processes to report a parent PID of 1 rely on the assumption that Process32First/Process32Next return parents before children. This isn't guaranteed by the API. Obtain all known PIDs on the first call to procps_scan() so that dead parents can be detected reliably. Costs 48 bytes.
2024-05-15win32: code shrinkRon Yorston1-2/+0
Saves 16-32 bytes
2024-05-14ps: report unknown parent PID as 1Ron Yorston2-2/+23
If the parent PID doesn't appear in the process table, report it as 1. This more closely matches how orphaned children are handled on UNIX. Adds 96-128 bytes. (GitHub issue #416)
2024-05-14kill: killing a zombie process should failRon Yorston3-114/+101
A process which has exited may still have its process handle held open by its children. Such a process doesn't appear in the process table. It is thus similar to a zombie process in UNIX. Using kill(1) to interact with such a process was seen to succeed, contrary to expectation. The code for "ordinary" signals in kill(2) did check if the process was still active but didn't treat an attempt to kill an inactive process as an error. Furthermore, sending SIGKILL or the fake signal 0 to a process didn't even check if the process was still active. Rearrange the implementation of kill(2) so that an attempt to signal an inactive process is treated as an error. This also consolidates handling of SIGKILL and signal 0 with "ordinary" signals. Saves 96 bytes. (GitHub issue #416)
2024-05-10ash: -X option shouldn't alter environment variablesRon Yorston1-3/+3
When a shell was started with the -X option, environment variables had forward slashes changed to backslashes. This is unnecessary and counterproductive. Adjust how the state of winxp is handled to avoid this. (GitHub issue #415)
2024-04-30win32: try to avoid downloading offline filesRon Yorston1-2/+5
It's possible that files in remote storage may not be available locally. Avoid downloading such files just to obtain file attributes. (GitHub issue #414)
2024-04-30ash: fix typoRon Yorston1-1/+1
2024-04-30ash: fix alias expansion followed by '&'Ron Yorston1-1/+10
An alias expansion immediately followed by '&' is parsed incorrectly: ~ $ alias x='sleep 2' ~ $ x& ~ $ sh: syntax error: unexpected "&" The sleep happens in the foreground and the '&' is left in the input buffer. The same problem occurs in upstream BusyBox but not dash. The difference between BusyBox and dash is that BusyBox supports bash-style output redirection (BASH_REDIR_OUTPUT in the code). This requires checking for '&>' in readtoken1(). 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 alias is then expanded and __pgetc() is called to fetch the next character. Since there are none left in the alias string __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(). Saves 32-48 bytes. (GitHub issue #413)
2024-04-29ash: add 'noiconify' optionRon Yorston1-11/+23
The 'noiconify' option controls how the console window is concealed when the 'noconsole' option is used. The default is to iconify the console. When 'noiconify' is 'on' the console is hidden. Adds 8-16 bytes. (GitHub issue #325)
2024-04-29ash: detect console state on every call to options()Ron Yorston1-3/+3
Commit 67ed7484be (ash: detect console state on shell start up) synchronised the noconsole option with the actual state of the window on shell start up. This is insufficient. The user can change the state of the window independently of the noconsole option, leading to confusion and unwanted iconification of the window when unrelated 'set' commands are issued. Detect the current console state on every call to options(). Saves 16-32 bytes. (GitHub issue #325)
2024-04-28build system: fix ncurses detectionRon Yorston1-1/+1
Recent versions of gcc fail to build the binary to test for ncurses because main() is lacking a return type.
2024-04-28libbb: make default history size configurableRon Yorston7-2/+21
Allow the default history size (used if HISTFILESIZE isn't set) to be configured at build time. This may be less than or equal to the standard history size. (GitHub issue #411)
2024-04-27lineedit: reduce default history sizeRon Yorston1-0/+4
Keep the maximum history size at 1023 but make the default 383. This gives a modest increase over the previous default of 255 while allowing users to increase or decrease the history size using the HISTFILESIZE environment variable. (GitHub issue #411)
2024-04-26lineedit: increase history size to 1023Ron Yorston4-4/+4
The upstream default history size is 255. Increase it to 1023 for default busybox-w32 builds. (GitHub issue #411)
2024-04-23make: code shrinkRon Yorston1-1/+1
The 'quick fix' in the previous commit unnecessarily checks the fractional timestamp value to determine if a target exists. This isn't how it's done elsewhere in the code.
2024-04-22make: better determine that a file is up-to-dateRon Yorston1-3/+5
POSIX says: A target shall be considered up-to-date... if it has already been made up-to-date by the current invocation of make (regardless of the target's existence or age). If the target does not exist after the target has been successfully made up-to-date, the target shall be treated as being newer than any target for which it is a prerequisite. Previously 'make' assumed that if a rule had succeeded the modification time of the target would be the current time. This isn't necessarily the case. Instead: - If the file exists use the modification time of the file as the the time of the target. - If it doesn't exist use the current time, which should be more recent than the time of any file for which it's a prerequisite. Adds 16 bytes. (GitHub issue #410)
2024-04-22win32: adjust handling of executable extensionsRon Yorston2-9/+13
Mixing Windows and Unix-style filename extensions was causing problems. Tweak how extensions are handled to try and improve matters: - Consistently check whether the unaltered filename is an executable before trying adding extensions. - Check .exe and .com before .sh. Saves up to 16 bytes. (GitHub issue #405)
2024-04-21make: allow mixed macros and targets on command lineRon Yorston2-8/+41
POSIX requires macro definitions to appear before targets on the command line. Allow mixed macros and targets as an extension. All macros on the command line are read first, then the targets are processed. Costs 64-80 bytes. (GitHub issue #406)
2024-04-21make: change how macros are read from the environmentRon Yorston1-2/+6
Originally there was no validation of macro names imported from the environment. However, process_macros() failed to account for the additional flag bit at this level. Thus, for example, SHELL was imported when it shouldn't have been. The problem the lack of validation was supposed to address was that of environment variables with invalid names, which the user may not have control over, causing a fatal error. As an alternative, silently ignore variables with invalid names on import from the environment.
2024-04-20make: skip shell -e option when running commandsRon Yorston2-2/+8
POSIX says, regarding execution of commands: The execution line shall then be executed by a shell as if it were passed as the argument to the system() interface, except that if errors are not being ignored then the shell -e option shall also be in effect. As a non-POSIX extension, skip the use of the -e option. This is how GNU make and BSD make behave. (GitHub issue #409)
2024-04-20win32: make stat(2) fail for /dev/zero, /dev/urandomRon Yorston1-1/+2
/dev/zero and /dev/urandom are only available internally and as arguments to 'dd'. Since users can't otherwise access them they shouldn't be treated as existing by stat(2). With this change stat(1) and test(1) will deny their existence. (GitHub issue #282)
2024-04-18yes: code shrinkRon Yorston1-5/+0
Now that putchar() is implemented using winansi_fputc() it isn't necessary to perform an explicit substitution in 'yes'. This was previously done so 'yes' could check for a broken pipe. Saves 16-32 bytes.
2024-04-18free: bloat reductionRon Yorston1-1/+1
Allow the compiler to inline parse_meminfo() so it can spot some optimisations. Saves 208-240 bytes.
2024-04-13lineedit: print prompt and editing operations to stderrDenys Vlasenko1-28/+34
For shells, this is mandated by standards function old new delta input_backward 215 231 +16 read_line_input 3015 3028 +13 draw_custom 66 78 +12 put_cur_glyph_and_inc_cursor 149 159 +10 put_prompt_custom 47 56 +9 show_history 40 46 +6 input_tab 927 933 +6 input_delete 136 142 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 78/0) Total: 78 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-04-13docproc: avoid segfault during file closingYan Zhu1-0/+1
In the function find_export_symbols, since the fopen file does not exit when it fails, there is a dereference problem in fclose(fp), which will cause a segmentation fault. Signed-off-by: Yan Zhu <zhuyan2015@foxmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-04-09ash: move setting of current directoryRon Yorston1-5/+7
The undocumented '-d' shell option is used to set the current directory in shells started by the 'su' applet of busybox-w32. In this case, the shell isn't a login shell. If a login shell sets the current working directory in /etc/profile it's possible the user may wish to override this with '-d'. This didn't work, though, because the directory is changed before /etc/profile is processed. Move the changing of the directory to that specified by '-d' so it happens after the processing of /etc/profile and ~/.profile. This won't affect the intended use of '-d'. (GitHub issue #403)
2024-04-09time: code shrinkRon Yorston1-4/+1
Commit 54dbf0fa5 (time: mitigation for interleaved output) added buffering to stderr in the 'time' applet. @avih pointed out that it isn't necessary to provide an explicit buffer. Saves 16 bytes in the 64-bit build. (GitHub issue #396)
2024-04-09ash: add title built-inRon Yorston3-2/+28
Implement a 'title' built-in for ash. It's very simple-minded, performs almost no error checking and is completely non-portable. - With no arguments it prints the current console title. - If arguments are provided the *first only* is set as the console title. Costs 88-116 bytes. (GitHub issue #401)
2024-04-08timeout: fix handling of timeoutsRon Yorston1-12/+7
The 'timeout' applet, by default, accepted fractional seconds but ignored the fraction. Moreover, in busybox-w32, even the integer part was incorrectly handled. Rewrite the (Windows) code to fix both problems. A patch has also been submitted to fix upstream. If that is accepted the Windows port will need to be updated to match. Saves 8-16 bytes. (GitHub issue #400)
2024-04-06win32: ascii-optimize winansi_fputc, winansi_putcharAvi Halachmi (:avih)1-8/+2
Other winansi IO wrappers, like winansi_fputs, optimize by calling the libc API directly if no special handling is needed, e.g. if the input is fully ASCII and without escape sequences - without converting the output codepage or interpreting escapes. Now the fputc and putchar wrappers do that as well. And as a simplification, putchar is now also a wrapper of fputc. Other than possibly minor speedup, this can also help buffered streams remain buffered, because the codepage conversion using writeCon_utf8 is unbuffered and first flushes the stream, so by avoiding the conversion and calling the libc API directly, we also avoid premature flush of a buffered stream. This did happen, as "time" is buffered since commit 54dbf0fa5, so previously it was flushed early when using putchar, while now it remains buffered by default (but can still be flushed early if the -f format string contains non-ASCII chars).
2024-04-06win32: UTF8_OUTPUT: flush stream before conversionAvi Halachmi (:avih)1-1/+3
writeCon_utf8 is unbuffered - it writes directly using WriteConsoleW, but some winansi libc IO wrappers, like fputs, use the libc API directly if the content doesn't need any special handling (e.g. all ASCII and no escape sequences), and so if the stream is buffered, and if only some parts of it go through writeCon_utf8, then we can get wrong output order due to some parts being buffered and some not. Case in point, the recent commit 54dbf0fa5 made the output of "time" buffered, and so if only parts of it go through writeCon_utf8, then we get bad output order. This did actually happen, because not all the winasi wrappers have this ASCII-only optimization (e.g. winansi_putchar), and "time" did end up with wrong output order. Even if all the winansi wrappers were ASCII-optimized, "time" could still have unicode output, e.g. with -f. Fix it by flushing the stream before converting using writeCon_utf8.
2024-04-06time: mitigation for interleaved outputRon Yorston1-0/+6
When the 'time' applet is run in a pipeline, like so: time seq 1 10 | tail -2 stdout from 'tail' and stderr from 'time' can be interleaved. This is particularly the case with the ConEmu terminal emulator. The interleaving can be reduced, though not eliminated, by buffering the output of 'time'. Adds 40-44 bytes. (GitHub issue #396)
2024-04-03md5/shaXsum: accept uppercase hex stringsRon Yorston1-0/+4
The coreutils versions of md5sum and the like accept uppercase hex strings from checksum files specified with the '-c' option. Use a case-insensitive comparison so BusyBox does the same. (GitHub issue #394)
2024-04-02win32: unicode: new wcwidth: allow enabling bidiAvi Halachmi (:avih)1-2/+5
interval, in_interval_table, and in_uint16_table were previously not compiled when using the new wcwidth (commit c188a345a) because they're used by the old wcwidth but not by the new one. But they're also used by the BIDI routines. mingw64u_defconfig doesn't enable bidi (rightly - it's not working well), but it'd still be nice to allow enabling bidi while the new wcwidth is in effect. Enable the tables lookup code if BIDI is enabled.
2024-03-29Revert "unicode: identify emoji width and modifiers"Avi Halachmi (:avih)1-8/+0
This reverts commit 878b3cd27fe83f2b0ff476b884c34d165be0072c. It's no longer required, since the last commit uses a new wcwidth implementation which covers the cases added by commit 878b3cd2 .