aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* xargs: fix 'xargs -sNUM' testsRon Yorston2019-01-061-0/+4
| | | | | The tests for 'xargs -sNUM' fail due to a missing newline unless it's output using fprintf rather than bb_putchar_stderr.
* tar: return correct exit code for empty tar fileRon Yorston2019-01-062-5/+4
| | | | | The WIN32 implementation of check_errors_in_children shouldn't have reset bb_got_signal as it's used to signal an error.
* busybox: add --uninstall optionRon Yorston2019-01-053-2/+72
| | | | | | | | | | | | | | | | | | Add an option to allow hard links to be removed. busybox --uninstall file removes all hard links to the given file (including the file itself.) Since Microsoft Windows refuses to delete a running executable a BusyBox binary is unable to remove links to itself. busybox --uninstall -n file displays the names of all hard links to the given file. Although this feature is couched in terms of uninstalling BusyBox it's actually quite general: it can be used to delete or display hard links to any file.
* busybox: identify scripts in output of 'busybox --list-full'Ron Yorston2019-01-051-0/+4
|
* lineedit: allow non-ASCII characters when tab-completing filenamesRon Yorston2019-01-051-0/+4
|
* win32: reduce static storage needed for lazy loadingRon Yorston2019-01-042-21/+15
| | | | | | Only the generic function pointer and initialisation flag need to be in static storage. The DLL and function names and the specialised function pointer can be local.
* win32: add support for %T to strftimeRon Yorston2018-12-161-21/+30
| | | | | | | | Add the %T format specifier (same as %H:%M:%S) to our emulation of strftime. Rewrite so that common code to replace a format specifier with a string is shared.
* ash: fix local PATH assignmentsRon Yorston2018-12-151-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | The previous commit included code to use PATH values assigned to local variables: PATH=/new/path:$PATH new_binary It didn't work in the case when no fork was needed, for example: (PATH=/new/path:$PATH new_binary) because the call to listsetvar() freed the PATH value that was passed to shellexec(). The forking case only worked because the spawn_forkshell() mechanism in busybox-w32 didn't allow the PATH value to be freed. Rewrite the code so it works whether or not a fork is needed. The code would also work on POSIX systems. A cleaner solution could be extracted from dash commit cbb71a8 'eval: Add assignment built-in support again' but neither that nor the current patch are suitable for submission to upstream BusyBox. This one is preferred because it requires fewer changes from upstream.
* win32: special treatment for PATHRon Yorston2018-12-147-82/+75
| | | | | | | | | | | | | | | | | The PATH shell variable is a special case. It can be exported to the environment where it might be interpreted by native applications which assume the separator is ';'. Hence: - require that the separator used in PATH is ';' - enforce this by intercepting calls to setvareq() that set PATH and adjusting its value if necessary. As a result of this the code to parse PATH can be simplified by replacing the hardcoded Unix ':' path separator by the platform- dependent macro PATH_SEP. The MANPATH variable is also required to use ';' as its separator but since it's less likely to be used this isn't enforced.
* ash: move code from setup_environment()Ron Yorston2018-12-143-15/+7
| | | | | | | ash calls setup_environment() but only uses a small amount of its functionality. Moving the code into ash itself means we don't need to customise setup_environment() for WIN32 and can remove it from the build.
* ash: prevent ctrl-c from killing background processesRon Yorston2018-12-131-0/+14
| | | | | | | | | | | | | | spawn_forkshell() was missing some code that would normally have been run from forkchild when a background process was started: - the ctrl-c handler wasn't disabled; - standard input wasn't connected to /dev/null. Using ctrl-c to kill a foreground process also killed background processes. Fixing this requires passing the forkshell mode and the number of processes associated with the forkshell job to the child process.
* ash: fix ctrl-c handling for pipelinesRon Yorston2018-12-131-43/+57
| | | | | | | | | | | There were two flaws in the implementation of ctrl-c handling in waitpid_child(): - processes associated with all jobs were killed; - all processes in a pipeline were killed but only the status of one was updated. As a result of the latter ctrl-c didn't reliably stop a pipeline.
* win32: emulate SIGPIPERon Yorston2018-12-117-14/+32
| | | | | | | | | | | | | | | | | | | The code to check whether a write error is due to a broken pipe can now either: - return with error EPIPE; - cause the process to exit with code 128+SIGPIPE. The default is the latter but the behaviour can be changed by issuing signal(SIGPIPE, SIG_IGN) and signal(SIGPIPE, SIG_DFL) calls. No actual signal is involved so kill can't send SIGPIPE and handlers other than SIG_IGN and SIG_DFL aren't supported. This does, however, avoid unsightly 'broken pipe' errors from commands like the example in GitHub issue #99: dd if=/dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
* win32: special treatment for files with the '.sh' extensionRon Yorston2018-12-092-36/+46
| | | | | | | | | | | | Files with the extension '.sh' are considered to be executable. Those that start with a '#!' line will be run using the specified interpreter. If no '#!' is present the script will be run by the shell. When searching for an executable the '.sh' extension will be tested in the same way as the standard extensions understood by spawnve(). '.sh' takes precedence over the standard extensions.
* win32: add a case-insensitive version of is_suffixed_with()Ron Yorston2018-12-093-2/+30
|
* ash: use auto_win32_extension() in tryexec()Ron Yorston2018-12-091-6/+3
|
* win32: use open_read_close() where possibleRon Yorston2018-12-092-12/+4
|
* lineedit: more case-insensitive comparisons in tab completionRon Yorston2018-12-083-0/+27
|
* lineedit: improvements to tab completionRon Yorston2018-12-085-12/+26
| | | | | | | | | | Since getpwent isn't implemented for WIN32 there's no point in enabling FEATURE_USERNAME_COMPLETION. Use case-insensitive comparisons when matching filenames. The code to exclude non-executables when tab completing executables is WIN32-specific and shouldn't omit directories.
* win32: allow execution of empty batch file to succeedRon Yorston2018-12-081-0/+8
| | | | | | | Microsoft Windows' spawnve returns ERROR_BAD_EXE_FORMAT when passed an empty batch file. Work around this by skipping spawnve and returning success.
* win32: (another) fix to file extension testRon Yorston2018-12-071-1/+1
| | | | | | | It turns out '.bat' is a valid batch file name. Reduce the permitted length for filenames to allow for this. Also, actually *use* the file basename in the test this time.
* win32: fix to file extension testRon Yorston2018-12-071-2/+3
| | | | | | | When looking for the special WIN32 file extensions only consider the file's basename, not the full path. Otherwise a file called '.bat', for example, is considered executable by 'ls -a' and the shell tries to run './.bat'.
* win32: improve execution of batch filesRon Yorston2018-12-071-26/+8
| | | | | | | | | It appears that when a batch file is executed the first argument must contain backslashes if it's a relative path. Absolute paths work either way. In both cases the extension is optional. This allows for a considerable simplification of the special case in spawnveq.
* win32: rework adding of extensions to filenamesRon Yorston2018-12-066-98/+64
| | | | | | | | | | | | | | | | | | | | | | | Previously there was one function to handle adding extensions to executable filenames, add_win32_extension(). Refactor this into three functions: add_win32_extension() appends the suffix to the argument string in-place. The argument must be long enough to cope with this, as is the case in ash where path_advance() adds 4 bytes to each filename for just this reason. alloc_win32_extension() is equivalent to the old add_win32_extension(). It allocates a string to hold the new filename then calls the new add_win32_extension() function. The caller is responsible for managing the returned string. auto_win32_extension() calls alloc_win32_extension() and saves the resulting string using auto_string(). It's used where the new filename is consumed immediately or the actual value isn't needed. Rewrite code to use the most appropriate function. Also reorder some code in find_executable() and find_command().
* ash: fix 'type' and 'command -v'Ron Yorston2018-12-051-1/+1
| | | | | | | | | | | | | | The 'type' and 'command -v' builtins could return incorrect information when their argument included a file separator. For example: $ command -v cmd C:/Windows/system32/cmd.exe $ command -v C:/Windows/system32/cmd.exe $ echo $? 127 Fix the faulty logic causing this.
* Merge branch 'busybox' into mergeRon Yorston2018-12-057-30/+58
|\
| * vi: correctly detect when a deletion empties the bufferRon Yorston2018-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Michał Berger has reported two issues: - Repeatedly deleting and undoing the deletion of the last line results in characters being lost from the end of the line. - Deleting the bottom line twice then attempting to undo each of these deletions results in a segfault. The problem seems to be an incorrect test for whether the text buffer is empty. Reported-by: Michał Berger <michallinuxstuff@gmail.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: code shrinkDenys Vlasenko2018-11-291-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta char_search 241 247 +6 get_one_address 275 272 -3 colon 2878 2875 -3 do_cmd 4726 4720 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 6/-12) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: fix FEATURE_VI_REGEX_SEARCH to respect LIMITED (one-line) searchDenys Vlasenko2018-11-291-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If busybox is compiled with FEATURE_VI_REGEX_SEARCH enabled, command ":s/x/y/" searches not only in the current line, but continues search after it. This makes range searches (":1,3s/x/y/") work incorrect. For example file "./test": 1 2 3 $ vi ./test :1,2s/3/e/ gives us: 1 2 e function old new delta char_search 213 241 +28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: do not misinterpret 0x10-0x19 chars in "\xNNN" tooDenys Vlasenko2018-11-291-6/+4
| | | | | | | | | | | | | | function old new delta bb_process_escape_sequence 141 151 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: @ in "\x3@" is not a valid hex digitDenys Vlasenko2018-11-291-2/+10
| | | | | | | | | | | | | | function old new delta bb_process_escape_sequence 134 141 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cat,nl: fix handling of open errorsDenys Vlasenko2018-11-294-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $ cat -n does_not_exist; echo $? cat: does_not_exist: No such file or directory 1 function old new delta print_numbered_lines 118 129 +11 nl_main 196 201 +5 cat_main 421 425 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 20/0) Total: 20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: abort if NF set to negative valueDenys Vlasenko2018-11-281-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: fix implementation of access(2)Ron Yorston2018-12-041-2/+5
| | | | | | | | | | | | | | | | | | The WIN32 implementation of access(2) didn't return: - the correct value when a directory was tested for X_OK; - the correct error code when the target existed but execute permission wasn't available.
* | ash: fix a couple of test casesRon Yorston2018-12-042-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The ash tests exitcode_EACCES and exitcode_ENOENT both failed. In commit 92dbd3c09 a test was added to tryexec to check that the file being run existed and was executable. The error codes returned by this test were incorrect. The slightly later commit f5783ef14 added a similar test in spawnveq which got the error codes right. Remove the test from tryexec and some superfluous error messages from spawnveq.
* | ash: forkshell tweaksRon Yorston2018-12-041-12/+13
| | | | | | | | | | | | | | | | Make it explicit that the nodeptr array contains pointers to pointers. In debug output show both the location of pointers to be fixed and their contents.
* | ash: more clean upRon Yorston2018-12-031-5/+5
| |
* | ash: code clean upRon Yorston2018-12-031-6/+1
| |
* | ash: improvements to forkshell debugRon Yorston2018-12-031-5/+23
| | | | | | | | | | | | | | | | If forkshell_print is passed a NULL file pointer it opens and closes a local one. Add the pid to the output file name so forkshell_print can be called from both parent and child.
* | ash: annotate pointers in forkshell debugRon Yorston2018-12-021-42/+130
| | | | | | | | | | | | | | Add some text to indicate the purpose of each pointer in the forkshell data block. The code isn't very efficient but it's only used for debug.
* | ash: redefine SAVE_PTR macros to remove testRon Yorston2018-12-021-2/+10
| | | | | | | | | | | | | | | | | | | | | | The SAVE_PTR macros are used to identify pointers that need to be fixed after forkshell. They're initially used in contexts where the nodeptr variable may be NULL, so have a test for this condition. Later uses are in places where nodeptr is known to have a non-NULL value so the macros can be redefined to remove the test. Saves over 100 bytes.
* | ash: consolidate tests for variables not to convertRon Yorston2018-11-291-8/+5
| | | | | | | | | | | | | | We usually convert backslashes to slashes when importing environment variables into the shell. Exceptions are if the user has set the -X option, SYSTEMROOT and COMSPEC. Perform these tests all at once rather than separately.
* | ash: fixes to spawn_forkshellRon Yorston2018-11-291-16/+10
| | | | | | | | | | | | | | If spawn fails: - raise an error in spawn_forkshell, not at each call site; - free the job by calling freejob, not free.
* | nologin: change defaultRon Yorston2018-11-291-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2018-11-2869-641/+2946
|\|
| * testsuite: check CONFIG_DESKTOP before using 'od -t'Chen Qi2018-11-277-5/+7
| | | | | | | | | | | | | | | | The '-t' option for od is enabled by CONFIG_DESKTOP. So check this config before using 'od -t' in test cases. Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: allow hush to run embedded scriptsRon Yorston2018-11-2710-32/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | Embedded scripts require a shell to be present in the BusyBox binary. Allow either ash or hush to be used for this purpose. If both are enabled ash takes precedence. The size of the binary is unchanged in the default configuration: both ash and hush are present but support for embedded scripts isn't compiled into hush. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * free: ensure there is a least one space between numbersDenys Vlasenko2018-11-271-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * docs: add embedded-scripts.txtRon Yorston2018-11-272-1/+117
| | | | | | | | | | Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tar: skip 'V' headers (GNU volume label), closes 11526Denys Vlasenko2018-11-271-1/+2
| | | | | | | | | | | | | | function old new delta get_header_tar 1696 1690 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>