aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: allow for trailing separator in PATHpath_searchRon Yorston2024-06-121-0/+12
| | | | | | | | | | | | | | | | | 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.
* libbb: make default history size configurableRon Yorston2024-04-282-2/+12
| | | | | | | | 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)
* win32: unicode: new wcwidth: allow enabling bidiAvi Halachmi (:avih)2024-04-021-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.
* Revert "unicode: identify emoji width and modifiers"Avi Halachmi (:avih)2024-03-291-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 .
* win32: unicode: use newer wcwidth by defaultAvi Halachmi (:avih)2024-03-292-0/+510
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new wcwidth implementation at libbb/wcwidth_alt.c, and uses it instead of the existing implementation when compiling for windows and CONFIG_LAST_SUPPORTED_WCHAR >= 0x30000 - which is the case with the unicode configs/mingw64u_defconfig. The windows-target condition keeps non-windows build unmodified, and the last supported wchar threshold is a semi-hack to allow switching between implementations without adding a new config option (the old code supports codepoints up to 0x2ffff). The new file wcwidth_alt.c was generated by a new scripts/mkwcwidth, which prints a wcwidth implementation using latest unicode data from a local clone of https://github.com/jquast/wcwidth . This repo is the main python wcwidth implementation, and is maintained and up to date. Functional differences from the existing implementation: - Unicode 15.1.0 (latest) with the new version (about 450 ranges of wide and zero-width codepoints), compared to roughly Unicode 5.0 of the existing code (nearly 20 years old spec, about 150 ranges). The new spec includes, among others, various wide icons and emojis, which can now be edited correctly at the shell prompt, have correct alignment in 'ls', etc. - The old implementation returns -1 (non-printable) for surrogates, while the new code returns 1, though this is inconsequential, and POSIX doesn't care. Also libc implementations vary in this regard. Technical differences: - The old version compiles less code/data when the last supported wchar is smaller, while the new version doesn't. This doesn't matter because the new version is enabled only for the full range. - The new version is smaller and relatively straight forward, and fully automated (generated), so updates to newer spec is trivial. The old version mixes data, ad-hoc code (tailored to the data), and preprocessor checks, and is hard to automate updates. The old version has various forms of 32 and 16 bit data ranges, in several arrays, while the new version uses single data array with unified form of 32 bits per range, with two rules: - A data range can't span Unicode planes (enforced, but unlikely required, and if yes, code to split ranges would be simple). - A range can't hold more than 32768 codepoints, so bigger ranges are split automatically (currently there are 2 such ranges). Performance wise, the new version should be faster, even with three times the data ranges. Both versions do effectively at most one binary search in one Unicode plane data, but the new version finds both zero-width and wide-width results in this one search, while the old version only finds zero-width, and to detect wide-width it does an additional linear series of manual range tests, but since most results are width 1, this sequence is performed in most (non-ASCII) calls. In a cursory comparison of the new wcwidth with glibc and musl-libc (both use O(1) lookup tables), with few bodies of text, we're in the same ballpark, with typical speed of 60% or better. Bloat-wise, the new version is about 180 bytes code and 1800 bytes data. If it had similar number of data ranges as the old code (150), the new version would be about 200 bytes smaller, but because the new version has 450 data ranges, it's about 1K bigger.
* build system: avoid full rebuild when EXTRAVERSION changesRon Yorston2024-02-161-0/+3
| | | | | | | | | | The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes.
* win32: stat(1) requires find_mount_point()Ron Yorston2024-02-021-0/+1
| | | | | | | | | | | In the Microsoft Windows build stat(1) requires find_mount_point() from libbb. This won't be available unless df(1) is also enabled. Add a dependency so stat(1) can be built without df(1). This may result in find_mount_point() being compiled needlessly in some upstream builds, but we can live with that. (GitHub issue #385)
* win32: rearrange applet override handlingRon Yorston2024-02-022-27/+29
| | | | | | | | | | - Rename some functions to be more meaningful. - Adjust conditional compilation to clarify which code is required for 'standalone shell' and 'exec prefers applets' settings. This shouldn't result in any change to the behaviour or size of default builds.
* win32: avoid invalid freeRon Yorston2024-01-241-3/+5
| | | | | | In external_exists() in appletlib.c it's necessary to take a copy of the pointer to the allocated variable path1 so it can be freed: find_executable() will change its value.
* Fix POSIX build in standalone shell modeRon Yorston2024-01-231-0/+2
| | | | | | | The conditional compilation to control standalone shell mode was incorrect when building for POSIX. This hadn't been noticed before as it had only been tested in the default configuration where standalone shell mode is disabled.
* Remove FAST_FUNC from variadic functionsRon Yorston2024-01-175-12/+12
| | | | | | | | | | | The GCC documentation points out that the stdcall attribute doesn't apply to functions which take a variable number of arguments. GCC is silent about this during compilation but clang complains noisily. Remove FAST_FUNC from all variadic functions. This has no effect whatsoever on the binary resulting from a default 32-bit build. Signed-off-by: Ron Yorston <rmy@pobox.com>
* Annual update of copyright messageRon Yorston2024-01-151-1/+1
|
* lineedit: remove CRs from inputRon Yorston2024-01-121-2/+6
| | | | | | | | | | | Commit 8ade494aeb (win32: add support for virtual terminal input) made some changes to how input is handled in the line editing code. In some circumstances (e.g. 'cat | sh -i') this results in input being read using fgets(3) rather than from the keyboard. Remove CRs from input in this case. Also, use fgets(3) if stdin is not a tty, but not stdout.
* libbb: code shrink bb_get_last_path_component_strip()Ron Yorston2024-01-041-6/+4
| | | | | Use the new function last_char_is_dir_sep() to save 16 bytes in bb_get_last_path_component_strip().
* libbb: introduce last_char_is_dir_sep()Ron Yorston2024-01-042-2/+13
| | | | | | | Add a convenience function to determine if the last character of a string is a directory separator. Adds 16-32 bytes.
* win32: make the clang build less crashyRon Yorston2024-01-031-0/+10
| | | | | | | | | | | | | busybox-w32 binaries built using clang crashed so frequently that they were pretty much unusable. The main issue seems to be with assignments to the structures containing global variables which are used in most applets. Upstream commit 5156b2455 (Make const ptr assign as function call in clang) addresses this, but is insufficient for the build on Windows. Extend the idea to the ASSIGN_CONST_PTR() macro too. Costs 32-80 bytes in the gcc build.
* httpd: fix failure to run daemonisedRon Yorston2023-12-151-2/+1
| | | | | | | | | | | | | | Since commit 2af141a2c (ash: changes to login shell functionality) httpd has failed to run in the background (i.e. without the '-f' option). This was due the removal of support for applet names with a '-' prefix. Although this feature isn't used by the shell it was used by httpd to mark when the process had been daemonised. Adds 16 bytes. (GitHub issue #378)
* lineedit: fix to tab completion of applet overrideRon Yorston2023-12-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | When the ability to override an applet if an external binary was present was added, the commit message for bd7018350 said: This doesn't affect tab completion in the shell: whether a completion is an applet or an external command is irrelevant. This isn't quite true. Suppose 'applet' has been overridden in such circumstances: $ export BB_OVERRIDE_APPLETS=";applet" $ applet If the user now enters tab twice the output would be: applet applet.exe The applet is still treated as a potential match. Recent changes to the applet override code result in a simple fix: the shell PATH can be passed to is_applet_preferred() in the line editing code. Now only 'applet.exe' is treated as a match. Adds 16-32 bytes.
* win32: tidy up conditional compilation of applet overrideRon Yorston2023-12-121-7/+6
| | | | | This doesn't affect the generated binary, at least in the default configuration.
* win32: code shrink applet overridesRon Yorston2023-12-102-13/+24
| | | | | | | | Pass the PATH to be used to look up executables down from the shell to the applet override code. This replaces the use of a static variable and a function to fetch its value. Saves 16-32 bytes.
* win32: allow hardcoded list of applets to overrideRon Yorston2023-12-091-3/+10
| | | | | | | | | | | | | The environment variable BB_OVERRIDE_APPLETS provides control over which applets are preferred in standalone shell mode. Allow a similar list to be hardcoded in the binary with the OVERRIDE_APPLETS configuration string. The environment variable is checked first. If it doesn't override the applet the hardcoded string is then checked too. The default for OVERRIDE_APPLETS is an empty string. In this case the size and behaviour of the binary is unchanged.
* Merge branch 'busybox' into mergeFRP-5236-g7dff7f376Ron Yorston2023-12-052-7/+17
|\
| * start-stop-daemon: do not lose error messages with -bDenys Vlasenko2023-11-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta start_stop_daemon_main 1186 1206 +20 bb_daemonize_or_rexec 196 212 +16 bb_banner 47 46 -1 packed_usage 34656 34645 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 36/-12) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sleep: fix "sleep -- ARGS"Denys Vlasenko2023-10-021-4/+11
| | | | | | | | | | | | | | | | | | | | | | function old new delta sleep_main 116 119 +3 printf_main 860 837 -23 single_argv 50 25 -25 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 3/-48) Total: -45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | lineedit: normalise HOME for use in promptRon Yorston2023-10-251-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | The code to replace the user's home directory with '~' in the prompt didn't allow for the possibility of the HOME environment variable having backslashes in the path. Convert backslashes to forward slashes in HOME. This isn't necessary if the home directory is obtained from getpwuid(3) as it's already converted there. Adds 24-32 bytes.
* | ash: add options to control globbing of hidden filesRon Yorston2023-09-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add shell options: - 'nohiddenglob' excludes files with the hidden attribute from globbing - 'nohidsysglob' excludes files with the hidden and system attributes from globbing If both options are enabled 'nohiddenglob' takes precedence. These options also affect tab completion. Files that are hidden because they start with a period aren't affected (unless they also have the hidden attribute). Costs 160-208 bytes. (GitHub issue #367)
* | ash: changes to login shell functionalityRon Yorston2023-08-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upstream BusyBox supports the usual Unix functionality where the login process adds a '-' prefix to the shell's argv[0]. Since busybox-w32 doesn't have a login process this serves no purpose and can be removed. Instead it would be useful to have a way to invoke a login shell without requiring any arguments. Advantages would be: - easier to configure busybox-w32 'ash' as the SSH login shell; - double clicking on a shell binary could start a login shell. Add 'lash' as an alias for 'ash' which starts a login shell without requiring the '-l' option. Saves 16 bytes.
* | libbb: fix #!/bin/busyboxRon Yorston2023-08-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 3476fb9f4c (ps: display interpreted script name in comm column) required the applet start up code to detect the index of the script in a shebang command line. When a script starts with '#!/bin/busybox' the argument list is shifted in busybox_main() but the script index wasn't adjusted to match. This caused the command to fail. Make the proper adjustment. Add 16 bytes. (GitHub issue #357)
* | win32: replace readlink(2)Ron Yorston2023-08-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Windows implementation of readlink(2) has caused problems in the past. As, for example, with commit c29dc205d2 (win32: fix implementation of readlink(2)). Most uses of readlink(2) in BusyBox are actually calls to the (considerably more convenient) library function xmalloc_readlink(). Implement a Windows version of that and used it instead of readlink(2). This improves the handling of symbolic links (and similar reparse points) in CJK and UTF-8 code pages. Saves 48-80 bytes.
* | libbb: change message regarding UTF-8 manifestRon Yorston2023-08-171-1/+1
| | | | | | | | | | When the UTF-8 manifest is included in the binary but the ANSI code page isn't UTF-8 report "UTF8 manifest not supported".
* | libbb: silence compiler warningsRon Yorston2023-08-101-1/+3
| |
* | Merge branch 'busybox' into mergeRon Yorston2023-08-107-8/+8
|\|
| * libbb: rename source files, no code changesDenys Vlasenko2023-07-187-8/+8
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: fail early if UTF8 isn't supportedRon Yorston2023-07-271-11/+20
| | | | | | | | | | | | | | | | | | When the UTF8 manifest is included in the binary and ACP isn't UTF8 fail at once. This avoids raising false hopes if the binary is run on Window 7/8. On Windows XP it won't even run. When the busybox applet is run without arguments always report the build-time configuration of globbing and the UTF8 manifest.
* | win32: version with UTF8 manifest: add '(Unicode on/off)'Avi Halachmi (:avih)2023-07-241-0/+4
| | | | | | | | | | | | When the UTF8 manifest is enabled at build time, then the version now includes a string indicating whether unicode is active (e.g. it's inactive on win 7/8, but should be active on Win10 1903+).
* | unicode: identify emoji width and modifiersAvi Halachmi (:avih)2023-07-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | This adds the Emoticons block U+1F600..U+1F64F as double-width codepoints, and the skin tone modifiers range U+1F3FB..U+1F3FF as combining codepoints. The Emoticons variant modifiers U+FE0E and U+FE0F were already in. It's unclear how to test UNICODE_COMBINING_WCHARS and UNICODE_WIDE_WCHARS in general and also here specifically, but at least the data on Emojis width and combinings now exits.
* | win32: use inc_cursor regardless of VT modeAvi Halachmi (:avih)2023-07-231-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | Commit 8ade494 added VT input support and, among others, disabled inc_cursor (in favor of the upstream busybox code) when the terminal has VT input enabled. However, inc_cursor works correctly regardless of the VT mode, and that condition was not required. Revert this condition (but still disable inc_cursor with unicode because it handles wide-glyphs incorrectly).
* | win32: support build with FEATURE_UNICODE_SUPPORTAvi Halachmi (:avih)2023-07-222-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FEATURE_UTF8_MANIFEST enables Unicode args and filenames on Win 10+. FEATURE_UTF8_INPUT allows the shell prompt to digest correctly Unicode strings (as UTF8) which are typed or pasted. This commit adds support for building with FEATURE_UNICODE_SUPPORT (mostly by supporting 32 bit wchar_t which busybox expects): - Unicode-aware line-edit - for the most part cursor movement/del being (UTF8) codepoint-aware rather than assuming that one-byte equals one-char-on-screen. - Codepoint-aware operations in some other utils, like rev or wc -c. - When UNICODE_COMBINING_WCHARS and UNICODE_WIDE_WCHARS are enabled, some screen-width-aware operations, like with fold, ls, expand, etc. The busybox Unicode support is incomplete, and even less so with the builtin libc replacement functions, like wcwidth, which are active when UNICODE_USING_LOCALE is unset (mingw lacks those functions). FEATURE_CHECK_UNICODE_IN_ENV should be set so that Unicode is not hardcoded but rather depends on the ANSI codepage and some env vars: LC_ALL=C disables Unicode support, else it's enabled if ACP is UTF8. There's at least one known issue where the tab-completion-prefix-case is not updated correctly, e.g. ~/desk<tab> completes to ~/desktop/ instead of ~/Desktop/, because the code which handles it exists only at the non-unicode code paths, but that's not very critical. That seems to be the only case where mingw-specific code is disabled when Unicode is enabled, but there could be other unknown issues. None of the Unicode options is enabled by default, and the next commit will make it easier to create a build which supports Unicode.
* | Merge branch 'busybox' into mergeRon Yorston2023-07-134-26/+14
|\|
| * libbb: code shrink: introduce and use [_]exit_FAILURE()Denys Vlasenko2023-06-151-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta exit_FAILURE - 7 +7 _exit_FAILURE - 7 +7 run 198 199 +1 restore_state_and_exit 114 115 +1 xbsd_write_bootstrap 399 397 -2 vfork_compressor 209 207 -2 sig_handler 12 10 -2 serial_ctl 154 152 -2 parse_args 1169 1167 -2 onintr 21 19 -2 make_new_session 493 491 -2 login_main 988 986 -2 gotsig 35 33 -2 do_iplink 1315 1313 -2 addgroup_main 397 395 -2 inetd_main 1911 1908 -3 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: pass "" rather than NULL as format string in _nomsg functionsDenys Vlasenko2023-06-123-26/+4
| | | | | | | | | | | | | | | | | | | | | | function old new delta bb_perror_nomsg_and_die 9 10 +1 bb_perror_nomsg 9 10 +1 bb_verror_msg 480 469 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 2/-11) Total: -9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: don't assume console CP equals OEM CPAvi Halachmi (:avih)2023-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, console input was converted to the ANSI codepage using OemToChar[Buff], and ANSI to console conversion used CharToOem[Buff]. However, while typically true by default, it's not guaranteed that the console CP is the same as the OEM CP. Now the code uses the console input/output CP as appropriate instead of the OEM CP. It uses full wide-char conversion code, which was previously limited to FEATURE_EURO, and now may be used also otherwise. While at it, the code now bypasses the conversion altogether if the src/dst CPs happen to be identical - which can definitely happen. Other than saving some CPU cycles, this also happens to fix an issue with the UTF8 manifest (in both input and output), because apparently the Oem/Char conversion APIs fail to convert one char at a time (which is not a complete UTF8 codepoint sequence) even if both the OEM and the ANSI CPs are UTF8 (as is the case when using UTF8 manifest). Conversion is also skipped: - if the converted output would be longer than the input; - if the input length is 1 and the input is multi-byte.
* | win32: more applet look-up tweaksRon Yorston2023-06-191-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an applet is overridden by BB_OVERRIDE_APPLETS it should still function in certain cases: busybox applet applet.exe busybox --help applet Arrange for this by adding really_find_applet_by_name() as a static function in libbb/appletlib.c. find_applet_by_name() is implemented using this for external use while really_find_applet_by_name() is used internally in some instances. Adds 32 bytes. (GitHub issue #329)
* | Merge branch 'busybox' into mergeRon Yorston2023-06-161-34/+68
|\|
| * libbb/dump: code shrinkDenys Vlasenko2023-05-281-5/+7
| | | | | | | | | | | | | | function old new delta .rodata 105252 105246 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/dump: make xxd_displayoff member conditional on xxdDenys Vlasenko2023-05-271-2/+10
| | | | | | | | | | | | | | | | | | With xxd not selected: function old new delta display 1459 1444 -15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/dump: correct handling of 1-byte signed int formatDenys Vlasenko2023-05-261-20/+17
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/dump: use fputs_stdout where appropriateDenys Vlasenko2023-05-261-2/+2
| | | | | | | | | | | | | | function old new delta display 1485 1483 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od, hexdump: byte 0x11 is "dc1" not "dcl"Denys Vlasenko2023-05-261-2/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>