aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* lineedit: case-insensitive matching for '~'Ron Yorston2022-05-111-0/+4
| | | | | | | | Use case-insensitive matching when determining if the directory name in the prompt can be shortened using '~'. This doesn't seem to have been a problem, as directories are often canonicalized, but it doesn't have any great cost.
* win32: make default PATH more likely to workRon Yorston2022-05-101-7/+10
| | | | | | | | | | | | | The default PATH defined as BB_PATH_ROOT_PATH is used: - to set PATH in the shell if the environment variable doesn't exist; - as the default in 'which' if there's no PATH env var; - when the option 'command -p' is given. Replace the Unix-centric default with something more likely to work on Microsoft Windows. No guarantees, though. (GitHub issue #253)
* ash: code shrinkRon Yorston2022-05-101-2/+1
| | | | | Changing one of the constants used by is_bb_var() saves a few bytes in the 32-bit build.
* ash: export certain variables to the environment immediatelyRon Yorston2022-05-086-6/+60
| | | | | | | | | | | The environment variables BB_OVERRIDE_APPLETS, BB_SKIP_ANSI_EMULATION and BB_SYSTEMROOT affect of the behaviour of the shell itself. Setting them as shell variables is insufficient for them to affect the current shell. When these three variables are exported from the shell they are now placed in the environment immediately. Conversely, when they're unset or unexported they're removed from the environment.
* win32: fix 'cd' to symlink with relative path as targetRon Yorston2022-05-071-1/+1
| | | | | | | | | | | | | Commit 69d328022 (win32: track current directory of mapped drives) replaced a call to xmalloc_realpath() with one to xmalloc_readlink(). This was incorrect. Although the argument is now guaranteed to be a symlink it's still necessary to resolve it to an absolute path. Otherwise the fix in commit 585d17d26 (win32: canonicalize path in chdir(2)) doesn't work for symlinks with a relative path as their target. (GitHub issue #147)
* ash: don't set OLDPWD on startupRon Yorston2022-05-071-1/+2
| | | | | | | | | | | | Commit f9b753e70 (ash: set current working directory on startup) set the current working directory of an interactive, non-login shell during startup to ensure drives mapped to a network share and symlinks were reported correctly. It had the side effect of setting OLDPWD. This is unnecessary because the current working directory won't have changed. (GitHub issue #253)
* win32: allow preference for applets to be disabled at runtimeRon Yorston2022-05-064-5/+61
| | | | | | | | | | | | | | | | The default busybox-w32 configuration enables the PREFER_APPLETS and SH_STANDALONE features. Sometimes it may be desirable to override the default preference for applets, for example, if an applet needs to be replaced by an external program with additional features. Add support for the environment variable BB_OVERRIDE_APPLETS. Its value may be: - a single dash ('-'): all applets are overridden; - a space-separated list of names: only the specified applets are overridden.
* win32: search PATH for missing Unix-style executablesRon Yorston2022-05-064-59/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 41ef232fc5 (win32: use built-in applets for non-existent binaries with Unix-style paths) alters what happens when trying to find an executable. If all of the following apply: - the pathname starts with one of the standard directories for Unix executables (/bin, /usr/bin, /sbin, /usr/sbin); - the file isn't found relative to the system root; - the basename matches an applet then the applet is run. Further extend the procedure so that if the first two conditions are met and either: - the PREFER_APPLETS and SH_STANDALONE features are enabled and the basename *doesn't* match an applet or - the PREFER_APPLETS and SH_STANDALONE features are disabled then PATH is searched for the basename. This affects: - how interpreters and binaries are spawned by mingw_spawn_interpreter() and mingw_spawnvp(); - how 'which' and the shell search for binaries. Special steps need to be taken in the shell to avoid treating shell built-ins and functions as applets. As a consequence of this change: - An executable that isn't an applet, say curl.exe, can be run as /usr/bin/curl so long as it's in a directory in PATH. It doesn't have to be in C:/usr/bin. - If the PREFER_APPLETS and SH_STANDALONE features are disabled binaries can be run using paths referring to standard Unix directories even if they're installed elsewhere in PATH.
* win32: better fix for empty environment variablesRon Yorston2022-05-053-9/+75
| | | | | | | | | | | | | | | | | | | It appears the CRT and OS each have a copy of the environment. mingw_putenv() fools the CRT into accepting an empty environment variable by calling _putenv("V=0") then truncating the new value by hand. But _putenv() also updates the OS environment with the fake 'V=0' value. Commit 5b48ca53b (win32: pass NULL to spawnve, not environ) resulted in this fake value being used and hence empty variables getting the value '0'. - Add a call to SetEnvironmentVariable() in mingw_putenv() to update the OS environment. - Restore the use of NULL environment pointers in mingw_spawnvp(). - Add a test. (GitHub issue #250)
* win32: revert changes related to environment variablesRon Yorston2022-05-042-12/+21
| | | | | | | | | | Revert the change to mingw_putenv() in the previous commit. When compiling for MSVCRT (i.e. not for UCRT) revert some of the changes from commit 5b48ca53b (win32: pass NULL to spawnve, not environ). (GitHub issue #250)
* win32: new code to set empty environment variableRon Yorston2022-05-031-12/+8
| | | | | | | | | | | | | | Windows environment variables: a never-ending source of fun. It seems the recent hack to work around problems in UCRT breaks the hack to set empty environment variables. The change to the empty variable isn't reflected in the environment seen by the C runtime. Use the WIN32 API to set the empty variable then set a dummy variable to make the C runtime take notice. (GitHub issue #250)
* which,ash: changes to which/command/typeRon Yorston2022-05-014-23/+67
| | | | | | | | | | | | | | | | | | | Change how 'which' detects if it was run from a standalone shell: the shell passes the undocumented '-s' option. This is stricter and more reliable than the previous method of checking the name of the binary. Add a function to determine the binary associated with a given applet name. This makes it possible for 'which' and 'command -v' to list the correct binary even for applets other than 'busybox'. For example, when the binary is called 'sh.exe' 'which sh' will report its path. In standalone shell mode 'command -V' and 'type' now report "xxx is a builtin applet" rather than "xxx is xxx", which is true but not very illuminating. (GitHub issue #248)
* win32: clarify documentation of is_relative_path()Ron Yorston2022-04-301-3/+8
|
* reset: applet should be NOEXEC for POSIXRon Yorston2022-04-301-1/+2
| | | | | | | | | The 'reset' applet was changed to be NOFORK for WIN32. Ensure that it remains NOEXEC in the POSIX build. The default POSIX configuration doesn't enable any of the features which need this information (PREFER_APPLETS, SH_STANDALONE and SH_NOFORK).
* ash: avoid misleading '.exe' in standalone shell modeRon Yorston2022-04-241-1/+1
| | | | | | | | | | | | | | In dash a command with an explicit path has an index value of -1 in its cmdentry structure. Upstream BusyBox extends this to allow other negative values for applets in standalone shell mode. busybox-w32 adds a further extension, with the index value INT_MIN indicating an applet with a Unix-style path. In describe_command() the command should only have a '.exe' extension added for index == -1, the original dash case of an explicit path. (GitHub issue #248)
* win32: conditional compilation in process.cRon Yorston2022-04-241-10/+10
| | | | | | | Drop the use of ENABLE_FEATURE_SH_STANDALONE in process.c In mingw_spawn_interpreter() check for an applet *before* trying to run the interpreter using the path provided.
* win32: proper conditional compilation in popen.cRon Yorston2022-04-231-9/+14
| | | | | | | | | | | In mingw_fork_compressor() the code to prefer applets over external programs should be conditionally compiled based on the setting of ENABLE_FEATURE_PREFER_APPLETS. In mingw_popen() there's no need to use ENABLE_FEATURE_SH_STANDALONE for the same purpose. ENABLE_FEATURE_PREFER_APPLETS is sufficient. Save a few bytes by sharing a format string in mingw_fork_compressor().
* date: enable FEATURE_DATE_NANORon Yorston2022-04-225-2/+16
| | | | | | | | | Provide a WIN32 implementation of clock_gettime(2), though only with support for CLOCK_REALTIME. This makes it possible to enable FEATURE_DATE_NANO which adds support for the %N date format. MinGW-w64 has clock_gettime(2) but it's in the winpthreads library and we don't want to bother with that.
* win32: minor adjustments to file permissionsRon Yorston2022-04-192-9/+10
| | | | | | | | | | | | | Mask the file permission bits in mingw_umask(), not when it's called from run_applet_no_and_exit(). Rather than hardcode write permissions for group and other in file_attr_to_st_mode() and mingw_fstat() make them respect the current umask setting. In mingw_fstat() there's no need to check the mode using S_ISDIR(): the hardcoded mode doesn't set S_IFDIR. The compiler had already figured this out so there's no reduction in bloat.
* Update default configurationRon Yorston2022-04-072-62/+76
|
* Merge branch 'busybox'Ron Yorston2022-04-0714-133/+196
|\
| * vi: improved handling of backspace in replace modeRon Yorston2022-03-041-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In replace mode ('R' command) the backspace character should get special treatment: - backspace only goes back to the start of the replacement; - backspacing over replaced characters restores the original text. Prior to this commit BusyBox vi deleted the characters both before and after the cursor in replace mode. function old new delta undo_pop - 235 +235 char_insert 858 884 +26 indicate_error 81 84 +3 find_range 654 657 +3 static.text_yank 77 79 +2 do_cmd 4486 4243 -243 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 4/1 up/down: 269/-243) Total: 26 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * taskset: fix printf format mismatch in !FEATURE_TASKSET_FANCY config. closes ↵Denys Vlasenko2022-03-011-2/+1
| | | | | | | | | | | | 14616 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: do not truncate failed tilde expansion on unknown user namesDenys Vlasenko2022-03-011-3/+1
| | | | | | | | | | | | | | | | | | | | | | Do not skip over "*p = c;" statement. Testcase: echo ~~nouser/qwe function old new delta argstr 1396 1406 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix unsafe use of mempcpyDenys Vlasenko2022-03-011-1/+7
| | | | | | | | | | | | | | function old new delta subevalvar 1549 1557 +8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: don't read past end of var in subvareval for bash substitutionsSören Tempel2022-03-015-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, BusyBox handles bash pattern substitutions without a terminating '/' character incorrectly. Consider the following shell script: _bootstrapver=5.0.211-r0 _referencesdir="/usr/${_bootstrapver/-*}/Sources" echo $_referencesdir This should output `/usr/5.0.211/Sources`. However, without this patch it instead outputs `/usr/5.0.211Sources`. This is due to the fact that BusyBox expects the bash pattern substitutions to always be terminated with a '/' (at least in this part of subvareval) and thus reads passed the substitution itself and consumes the '/' character which is part of the literal string. If there is no '/' after the substitution then BusyBox might perform an out-of-bounds read under certain circumstances. When replacing the bash pattern substitution with `${_bootstrapver/-*/}`, or with this patch applied, ash outputs the correct value. Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: update config help text with new performance numbersDenys Vlasenko2022-02-181-3/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha256: explicitly use sha256rnds2's %xmm0 (MSG) argumentDenys Vlasenko2022-02-122-70/+70
| | | | | | | | | | | | Else, the code seemingly does not use MSG. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * whitespace fixesDenys Vlasenko2022-02-112-11/+11
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: revert last commit: pshufb is a SSSE3 insn, can't use itDenys Vlasenko2022-02-116-115/+163
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: shrink unrolled x86-64 codeDenys Vlasenko2022-02-112-123/+117
| | | | | | | | | | | | | | function old new delta sha1_process_block64 3481 3384 -97 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha: improve commentsDenys Vlasenko2022-02-104-21/+20
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * whitespace fixDenys Vlasenko2022-02-094-10/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: let $HOME set home directory of login shellRon Yorston2022-03-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In busybox-w32 the shell option '-l' sets HOME to the user's home directory, as determined by a call to GetUserProfileDirectory(). This is differs from how shells work on Unix, where HOME is usually set by login(1). Allow the user to override this behaviour by setting HOME before starting the shell. If HOME isn't set or contains an empty string the previous behaviour applies. If HOME is set to a non-empty string the user should ensure that it represents a valid absolute path. (GitHub issue #244)
* | Fix POSIX buildFRP-4621-gf3c5e8bc3Ron Yorston2022-02-271-2/+2
| | | | | | | | | | Commit e6238530e (cpio: code shrink with !FEATURE_EXTRA_FILE_DATA) broke the POSIX build by incorrectly excluding chunks of code.
* | ash: try harder to avoid ctrl-c issueRon Yorston2022-02-271-24/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 96a647690 (ash: prevent issue with ctrl-c and echo in loop) attempted to fix the problem that interrupting a loop like: while true; do echo hello; done caused the shell to exit. However, it wasn't completely effective and it only applied to echo and printf, not other builtins. Revert 96a647690 and instead don't call raise_interrupt() from crtl_handler() for the foreground interactive shell.
* | win32: fake file ownership on FAT filesystemsRon Yorston2022-02-171-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | busybox-w32 tries to display the ownership of files by comparing the security identifier (SID) of the current user with that of the file on disk. For filesystems that don't support SIDs this resulted in files being listed as owned by root. It appears that filesystems without support for file ownership return a null SID. In such cases pretend the file belongs to the current user. GitHub issue #241.
* | Increment date in resourcesRon Yorston2022-02-141-1/+1
| |
* | ash: workaround for UCRT bugRon Yorston2022-02-121-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There seems to be a bug in UCRT such that if a process has been started by passing a non-NULL environment block to CreateProcess() any subsequent call to spawnve() with a non-NULL environment pointer results in a crash. Commit 5b48ca53b (win32: pass NULL to spawnve, not environ) fixed the problem in busybox-w32 for those cases where a NULL environment pointer was sufficient. It didn't handle the case where the shell passes a modified environment to its child. All calls to spawnve() in the shell occur in a process which will terminate whether or not the call succeeds. It therefore doesn't matter if we mess with the environment of this process to allow spawnve() to be passed a NULL environment pointer. Do this for UCRT builds only. (GitHub issue #234)
* | cpio: code shrink with !FEATURE_EXTRA_FILE_DATARon Yorston2022-02-102-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The new --renumber-inodes option won't work if FEATURE_EXTRA_FILE_DATA is disabled. Don't allow it to be selected in that case. In fact, if FEATURE_EXTRA_FILE_DATA is disabled all the code to handle hardlinks can be #ifdef'ed out. The new --ignore-devno option need do nothing if FEATURE_EXTRA_FILE_DATA is disabled, as in that case the device ids will already be zero. It can still be selected, cpio will just always behave as though the option was provided on the command line. This doesn't affect the size of the default build.
* | find: -samefile requires FEATURE_EXTRA_FILE_DATARon Yorston2022-02-091-1/+1
| | | | | | | | | | Without FEATURE_EXTRA_FILE_DATA we don't have inode numbers to match so -samefile won't work.
* | Fix POSIX build; new yearRon Yorston2022-02-092-2/+3
| |
* | Merge busybox into mergeRon Yorston2022-02-0963-836/+1969
|\| | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * libbb/sha256: code shrink in x86 assemblyDenys Vlasenko2022-02-092-12/+10
| | | | | | | | | | | | | | | | function old new delta sha256_process_block64_shaNI 32-bit 676 673 -3 sha256_process_block64_shaNI 64-bit 680 677 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha256: code shrink in 64-bit x86Denys Vlasenko2022-02-091-11/+14
| | | | | | | | | | | | | | function old new delta sha256_process_block64_shaNI 701 680 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-091-13/+16
| | | | | | | | | | | | | | function old new delta sha256_process_block64_shaNI 697 676 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha256: code shrink in 32-bit x86Denys Vlasenko2022-02-092-123/+114
| | | | | | | | | | | | | | function old new delta sha256_process_block64_shaNI 713 697 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: shrink x86 hardware accelerated hashing (32-bit)Denys Vlasenko2022-02-082-7/+5
| | | | | | | | | | | | | | function old new delta sha1_process_block64_shaNI 511 507 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: shrink x86 hardware accelerated hashing (32-bit)Denys Vlasenko2022-02-081-6/+5
| | | | | | | | | | | | | | function old new delta sha1_process_block64_shaNI 517 511 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/sha1: shrink x86 hardware accelerated hashingDenys Vlasenko2022-02-082-32/+29
| | | | | | | | | | | | | | | | function old new delta sha1_process_block64_shaNI 32-bit 524 517 -7 sha1_process_block64_shaNI 64-bit 510 508 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>