aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | 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>
| * libbb/dump: conditionalize code used only by xxd and odDenys Vlasenko2023-05-261-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: stop printing extra trailing spacesDenys Vlasenko2023-05-251-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 104598 104613 +15 display 1475 1485 +10 od_main 549 556 +7 rewrite 971 967 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 32/-4) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -sDenys Vlasenko2023-05-251-8/+22
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: code shrink applet look-upRon Yorston2023-06-051-20/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove find_preferred_applet_by_name(). Instead add a reference to is_applet_preferred() in find_applet_by_name(). - Remove the global variable ash_path. Use a static instead, accessed by calling get_ash_path(). - Mark ash_applet_by_name() as NOINLINE. Saves 64-96 bytes. (GitHub issue #329)
* | win32: another BB_OVERRIDE_APPLETS fixRon Yorston2023-06-041-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for conditionally replacing applets with external commands requires the ability to check whether a given command name is present on PATH. This was being done using the PATH environment variable, which works in commands run by the shell but not in the shell itself. - The shell uses the *shell* variable PATH to look for executables. This may not be the same as the *environment* variable. - 'command -p' uses an entirely different PATH. Applet look-up in the shell is now treated as a special case, with the actual PATH being used passed to the look-up code in a global variable. This doesn't affect tab completion in the shell: whether a completion is an applet or an external command is irrelevant. Costs 152-288 bytes. (GitHub issue #329)
* | win32: change interpretation of BB_OVERRIDE_APPLETSRon Yorston2023-06-021-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the following changes to BB_OVERRIDE_APPLETS: - Applet names in the list can be separated by spaces, commas or semicolons. - Applets before the first semicolon are disabled unconditionally. - Applets after the first semicolon are overridden if a matching external command exists. - '-' alone disables all applets. - '+' alone overrides every applet for which a matching external command exists. This doesn't change the existing documented behaviour. It adds the ability to have applets overridden if an external command exists but to remain available if not. Adds 80-88 bytes. (GitHub issue #329)
* | win32: case-sensitivity in tab completionRon Yorston2023-04-192-43/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tab-completion code treated all matches as case-insensitive because that's how Microsoft Windows handles filenames. This is now inadequate, as shell builtins, functions and aliases are case sensitive. Modify the treatment of case-sensitivity in tab completion: - Track whether each potential match is case-insensitive (filename) or case-sensitive (shell builtin, function or alias). - When comparing matches use a case-insensitive comparison if either value is a filename. Otherwise use a case-sensitive comparison. Adds 64 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2023-04-173-12/+10
|\|
| * lineedit: fix crash when icanon set with -echoAkos Somfai2023-04-121-2/+2
| | | | | | | | | | | | | | | | | | When icanon is set with -echo (e.g. ssh from an emacs shell) then S.state will remain null but later it will be deferenced causing ash to crash. Fix: additional check on state. Signed-off-by: Akos Somfai <akos.somfai@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * appletlib: fix "warning: unused variable applet_no"Tomas Paukrt2023-04-101-1/+1
| | | | | | | | | | Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix sleep built-in not running INT trap immediately on ^CDenys Vlasenko2023-04-101-9/+7
| | | | | | | | | | | | | | function old new delta sleep_for_duration 169 149 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | wget: enable progress bar in default configurationRon Yorston2023-04-161-1/+1
| | | | | | | | | | | | For some reason the progress bar in wget has never been enabled. Costs 1536-1600 bytes.
* | libbb: don't build useless functionsRon Yorston2023-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | The functions ndelay_on(), ndelay_off() and close_on_exec_on() don't do anything useful because our fcntl(2) implementation doesn't support the features they require. Replace them with stubs. Saves 176-208 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2023-04-092-16/+22
|\|