aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | win32: revert 'don't set error mode'Ron Yorston2024-06-222-29/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit eb376b5d1 (win32: don't set error mode) removed a call to SetErrorMode(SEM_FAILCRITICALERRORS). But the documentation says: Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application. Doing this prevents the system from displaying useful information, though. The application should attempt to tell the user what went wrong. Reinstate the call to SetErrorMode() and try to provide an error message, at least for the situation mentioned in issue #423 and other similar cases. Adds 360-368 bytes. (GitHub issue #423)
* | ash: allow HISTFILE=/dev/null to work as intendedRon Yorston2024-06-191-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was noted that setting HISTFILE=/dev/null in upstream BusyBox prevented shell history from being saved to a history file. This failed in busybox-w32 with an error from lseek(2). The lseek(2) wrapper was rather conservative in the file types it accepted. Allowing FILE_TYPE_CHAR makes it possible to seek on /dev/null, thus avoiding the issue with HISTFILE. In addition, the wrapper for open(2) now converts the Unix-style mode argument to Windows-style. (GitHub issue #425)
* | win32: code shrink APE detection; avoid UBRon Yorston2024-06-191-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Detecting Actually Portable Executable binaries used a longer signature than seems necessary. Six characters should be enough for anyone. When right shifting a byte by 24 bits, cast it to unsigned to avoid undefined behaviour. Saves 24-32 bytes. (GitHub issue #424)
* | make: update default rulesRon Yorston2024-06-161-14/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | The default rules were changed in the 2024 standard: - Fortran is no longer supported - The CC macro is set to 'c17' instead of 'c99' In addition to these changes, CC is set to 'cc' as a non-POSIX extension: on my system, at least, there isn't a 'c17' compiler. Adds 208-224 bytes.
* | win32: detect Actually Portable Executable binariesRon Yorston2024-06-161-15/+23
| | | | | | | | | | | | | | | | | | Check for the signature of Actually Portable Executable binaries and treat them as executable. Adds 40-64 bytes. (GitHub issue #424)
* | win32: don't set error modeRon Yorston2024-06-161-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a8c63f25b3 (win32: improve filesystem detection and display) added a call to SetErrorMode(SEM_FAILCRITICALERRORS). This was on the strength of the documentation for GetVolumeInformation() which suggests that otherwise a message box will appear to prompt the user to put media in an empty floppy or CD drive. This would disrupt the expected behaviour of applets like 'df'. In practice it seems the call to SetErrorMode() is unnecessary. It also results in other errors going unreported. Remove the call to SetErrorMode(). Saves 8-20 bytes. (GitHub issue #423)
* | make: update for POSIX 2024Ron Yorston2024-06-146-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | Now that POSIX.1-2024 has been released we can replace all references to the 202X draft standard with 2024. Make this change throughout the code and testsuite. The pragma 'posix_2024' has been added. 'posix_202x' remains as an alias for the same. The 2024 standard is enforced by default in POSIX mode.
* | win32: allow for trailing separator in PATHRon Yorston2024-06-144-38/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In recent versions of Windows the PATH environment variable has a trailing semicolon. This is insignificant to Windows because it's ignored. busybox-w32 conforms to the POSIX interpretation of PATH which treats an empty path element as denoting the current directory. As result, on these versions of Windows executables may by default be run from the current directory, contrary to usual Unix practice. Attempt to detect and remove the trailing semicolon on applet start up. If the user insists, they can add a trailing semicolon to the shell variable PATH and it will be respected in the conventional manner. Adds 88-112 bytes. (GitHub issue #422)
* | make: limit changes to pragmasRon Yorston2024-06-101-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The special target .PRAGMA could be used to set or reset pragmas. Doing anything other than setting pragmas very early in execution is likely to be problematic. Limit the abilities of .PRAGMA: - Specifying .PRAGMA with no prerequisites now does nothing: pragmas are not reset. - The posix_2017 and posix_202x pragmas can only be used to change the enforced POSIX level from the default. Any further attempt to change POSIX level results in a warning. Adds 16-32 bytes.
* | make: allow := macro assignment on command lineRon Yorston2024-06-081-14/+22
| | | | | | | | | | | | | | | | | | Only the forms of macro assignment required by POSIX were allowed on the command line. Add support for the non-POSIX := form too. Adds 16-24 bytes.
* | make: more changes for c:/path targetRon Yorston2024-06-051-4/+5
| | | | | | | | | | | | | | | | | | | | The previous commit failed to change an instance of find_char() to find_colon(). It isn't necessary to use find_char() to replace find_colon() in the non-Windows case: strchr(3) is sufficient. Adds 16-48 bytes.
* | make: restore check for c:/path targetRon Yorston2024-06-051-1/+23
| | | | | | | | | | | | | | | | | | | | Commit f9d10b2b6 (make: fix detection of target rules (take 2)) failed to include the function find_colon() which is used to skip targets of the form c:/path when checking for a target rule. Restore the function so Windows paths can be used as targets. Adds 48 bytes.
* | make: explicitly verify order of argumentsRon Yorston2024-06-041-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX requires macro assignments to precede targets on the command line. This requirement has been relaxed as a non-POSIX extension. Verify the constraint has been applied in POSIX mode. This ensures that the command: make --posix target A=1 fails before it tries to update the target. It also catches the case where POSIX mode had not been set with the --posix option or PDPMAKE_POSIXLY_CORRECT environment but was then set by the .POSIX special target in the makefile. In this case the command line was scanned for macro assignments without enforcing POSIX mode while targets were processed with POSIX mode enabled. Adds 96 bytes.
* | make: only reset getopt(3) if necessaryRon Yorston2024-06-031-2/+2
| | | | | | | | Only invoke GETOPT_RESET() if getopt(3) has actually been called.
* | make: ensure sufficient space in line bufferRon Yorston2024-06-021-7/+8
| | | | | | | | | | | | | | | | | | | | | | When using fgets(3) to read a line into a buffer it's necessary to ensure at least two characters are available in the buffer. Otherwise the read fails. (At least, it did when pdpmake was built using MSYS2 on Windows.) Adds 16 bytes to the 32-bit build. (GitHub pdpmake issue 44)
* | make: report POSIX 202X issue with includeRon Yorston2024-06-021-6/+12
| | | | | | | | | | | | | | | | | | | | | | Synchronising with upstream pdpmake showed that a test was missing from the BusyBox port. POSIX 202X doesn't specify what should happen if an include statement has no arguments. When the POSIX 202X standard is being enforced this is reported as an error. Adds 32 bytes.
* | make: restore warning about invalid macro nameRon Yorston2024-06-021-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | Commit 90c5352a9 (make: change how macros are read from the environment) was intended to ignore environment variables with invalid names. It had the unintended consequence of also ignoring macros with invalid names defined in makefiles. This was because such macros can have the same level (3) as those imported from the environment. Rather than use the level to detect importing from the environment add a flag to indicate this circumstance.
* | make: move test for complex chain of macro assignmentsRon Yorston2024-06-011-14/+14
| | | | | | | | | | | | The test 'Complex chain of macro assignments' relies on recursive macro expansion. This is a POSIX 202X feature, so the test should be moved to the appropriate section of the test script.
* | make: fix detection of target rules (take 2)Ron Yorston2024-05-312-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)
* | make: allow :::= macro assignment on command lineRon Yorston2024-05-292-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.
* | make: relax the test 'Return error if command fails'Ron Yorston2024-05-291-1/+1
| | | | | | | | | | The test 'Return error if command fails' needed an exit code of 2. POSIX only requires an exit code greater than 0.
* | make: fixes to -q optionRon Yorston2024-05-282-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.
* | make: fixes to -t optionRon Yorston2024-05-282-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.
* | make: improved support for POSIX levelsRon Yorston2024-05-275-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.
* | make: add posix_2017 pragmaRon Yorston2024-05-251-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.
* | make: fix tests for BSDRon Yorston2024-05-241-4/+4
| | | | | | | | | | | | A couple of tests require backslashes to be escaped. The test for CURDIR should use 'pwd -P' to resolve symlinks.
* | make: add support for ifeq/ifneqRon Yorston2024-05-222-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.
* | make: set $< and $* for target rulesRon Yorston2024-05-222-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)
* | make: add support for CURDIR macroRon Yorston2024-05-222-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.
* | ash: fix commentRon Yorston2024-05-221-1/+1
| |
* | ash: prevent mintty from setting HOMERon Yorston2024-05-211-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)
* | win32: some changes to kill(2)Ron Yorston2024-05-181-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.
* | win32: implement getppid(2)Ron Yorston2024-05-162-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.
* | win32: ensure PIDs are read early in procps_scan()Ron Yorston2024-05-162-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.
* | win32: code shrinkRon Yorston2024-05-151-2/+0
| | | | | | | | Saves 16-32 bytes
* | ps: report unknown parent PID as 1Ron Yorston2024-05-142-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)
* | kill: killing a zombie process should failRon Yorston2024-05-143-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)
* | ash: -X option shouldn't alter environment variablesRon Yorston2024-05-101-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)
* | win32: try to avoid downloading offline filesRon Yorston2024-04-301-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)
* | ash: fix typoRon Yorston2024-04-301-1/+1
| |
* | ash: fix alias expansion followed by '&'Ron Yorston2024-04-301-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)
* | ash: add 'noiconify' optionRon Yorston2024-04-291-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)
* | ash: detect console state on every call to options()Ron Yorston2024-04-291-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)
* | build system: fix ncurses detectionRon Yorston2024-04-281-1/+1
| | | | | | | | | | Recent versions of gcc fail to build the binary to test for ncurses because main() is lacking a return type.
* | libbb: make default history size configurableRon Yorston2024-04-287-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)
* | lineedit: reduce default history sizeRon Yorston2024-04-271-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)
* | lineedit: increase history size to 1023Ron Yorston2024-04-264-4/+4
| | | | | | | | | | | | | | The upstream default history size is 255. Increase it to 1023 for default busybox-w32 builds. (GitHub issue #411)
* | make: code shrinkRon Yorston2024-04-231-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.
* | make: better determine that a file is up-to-dateRon Yorston2024-04-221-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)
* | win32: adjust handling of executable extensionsRon Yorston2024-04-222-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)