aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'busybox' into mergeRon Yorston2023-04-171-1/+1
|\
| * 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>
* | win32: delay adjusting code pageRon Yorston2023-03-171-3/+1
| | | | | | | | | | | | | | | | | | | | | | Commit 93a63809f9 (win32: add support for the euro currency symbol) caused all invocations of busybox-w32 to change code page 850 to 858. This has been known to cause problems with fonts in PowerShell (GitHub issue #207). Delay changing the code page until an i/o operation is imminent. Instances of PowerShell started by the `drop` applet during ssh login thus no longer have their code page adjusted.
* | Annual update of copyright messageRon Yorston2023-01-051-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2022-10-121-3/+5
|\|
| * fix [ --help ] and [[ --help ]]Denys Vlasenko2022-08-301-0/+3
| | | | | | | | | | | | | | function old new delta show_usage_if_dash_dash_help 72 79 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: make '--help' handling more consistentRon Yorston2022-08-221-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running an applet with '--help' as its only argument is treated as a special case. If additional arguments follow '--help' the behaviour is inconsistent: - applets which call single_argv() print help and do nothing else; - applets which call getopt() report "unrecognized option '--help'" and print help anyway; - expr says "expr: syntax error" and doesn't print help; - printenv silently ignores '--help', prints any other variables and doesn't print help; - realpath says "--help: No such file or directory", prints the path of any other files and doesn't print help. If the first argument is '--help' ignore any other arguments and print help. This is more consistent and most likely what the user wanted. See also commit 6bdfbc4cb (libbb: fix '--help' handling in FEATURE_SH_NOFORK=y). function old new delta show_usage_if_dash_dash_help 75 69 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-6) Total: -6 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2022-05-121-1/+1
|\|
| * style fixDenys Vlasenko2022-05-011-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: export certain variables to the environment immediatelyRon Yorston2022-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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: allow preference for applets to be disabled at runtimeRon Yorston2022-05-061-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: minor adjustments to file permissionsRon Yorston2022-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix POSIX build; new yearRon Yorston2022-02-091-1/+1
| |
* | Merge busybox into mergeRon Yorston2022-02-091-1/+1
|\| | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" function old new delta .rodata 108586 108460 -126 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes text data bss dec hex filename 970412 4219 1848 976479 ee65f busybox_old 970286 4219 1848 976353 ee5e1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-10-131-9/+14
|\|
| * shell: fix script's comm field if ENABLE_FEATURE_PREFER_APPLETS=yDenys Vlasenko2021-10-111-2/+8
| | | | | | | | | | | | | | | | | | | | function old new delta re_execed_comm - 46 +46 main 72 86 +14 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Make const ptr assign as function call in clangYU Jincheng2021-10-091-1/+1
| | | | | | | | | | | | | | | | - This can act as memory barrier in clang to avoid read before assign of a const ptr Signed-off-by: LoveSy <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * *: generalize "const trick"YU Jincheng2021-10-071-2/+1
| | | | | | | | | | | | | | | | While at it, change all "__asm__" to "asm" Co-authored-by: canyie <31466456+canyie@users.noreply.github.com> Signed-off-by: YU Jincheng <shana@zju.edu.cn> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: code shrink in main() and scripted_main()Denys Vlasenko2021-09-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta main 68 65 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes text data bss dec hex filename 1472 560 16 2048 800 busybox_old 1398 552 16 1966 7ae busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * busybox: fix "busybox --help busybox" not showing correct textDenys Vlasenko2021-08-161-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | busybox: bring help handling into line with upstreamRon Yorston2021-08-161-5/+5
| | | | | | | | | | Upstream has fixed a problem with 'busybox --help' so it's possible to remove another gratuitous divergence.
* | busybox: make 'busybox --help busybox' workRon Yorston2021-05-141-0/+4
| | | | | | | | | | Upstream changes broke the 'busybox --help busybox' command. Fix it.
* | Merge branch 'busybox' into mergeRon Yorston2021-05-141-8/+22
|\|
| * echo: special case "echo --help": it should not show help textDenys Vlasenko2021-03-151-8/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | While at it, fix "busybox --help echo" and other special applets to still print the help text. function old new delta run_applet_and_exit 732 761 +29 show_usage_if_dash_dash_help 70 78 +8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 37/0) Total: 37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: special case for busybox --help is WIN32-onlyRon Yorston2021-04-091-1/+1
| | | | | | | | | | | | Commit 32833bc06 (ash: treat all applets as NOEXEC) added special treatment for 'busybox --help'. This should only be included for WIN32 builds.
* | libbb: allow single-applet binary to buildRon Yorston2021-03-141-11/+10
| | | | | | | | | | | | The ability to build a single-applet binary was lost following commit 33a914da6b (ps: obtain applet names from other BusyBox processes).
* | busybox: allow '--install' to install symlinksFRP-3902-g61e53aa93Ron Yorston2021-03-021-43/+39
| | | | | | | | | | | | Restore the '--install -s' option which allows BusyBox to install symbolic links. Of course, this will only work if the user has permission to create symlinks.
* | Merge branch 'busybox' into mergeRon Yorston2021-03-011-30/+40
|\|
| * libbb: fix '--help' handling in FEATURE_SH_NOFORK=yDenys Vlasenko2021-02-181-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most BusyBox applets respond to the '--help' option by printing a usage message. This is normally handled by busybox_main() so applet main routines don't have support for '--help'. In standalone shell mode with FEATURE_SH_NOFORK enabled nofork applets are invoked directly, bypassing busybox_main(). This results in inconsistent handling of '--help': - applets which call getopt() report "unrecognized option '--help'" and print help anyway; - realpath says "--help: No such file or directory" and doesn't print help; - usleep says "invalid number '--help'" and doesn't print help. Avoid inconsistency by checking for '--help' in run_nofork_applet(). Bug found by Ron Yorston. function old new delta show_usage_if_dash_dash_help - 70 +70 run_nofork_applet 347 362 +15 run_applet_no_and_exit 432 365 -67 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 85/-67) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: make banner shorterRon Yorston2021-02-161-2/+2
| |
* | Merge branch 'busybox' into mergeRon Yorston2021-02-051-79/+17
|\|
| * libbb: code shrink and speed up find_applet_by_name()Ron Yorston2021-02-021-79/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | find_applet_by_name() determines the appropriate range of applet indices to check for the given name and performs a linear search in applet_names[]. Revise the code so the index of the upper bound of the range, 'max', isn't calculated. Instead check the value of the first non-matching character to see if we've reached the end of the range. This new code speeds up the time to find a valid applet name by 6% and halves the time to detect that a given name is invalid. The average time to detect an invalid name is now the same as for a valid one. function old new delta find_applet_by_name 155 133 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright messageRon Yorston2021-01-131-1/+1
| | | | | | | | Hey, look! It's 2021 already.
* | Merge branch 'busybox' into mergeRon Yorston2020-11-121-2/+7
|\|
| * libbb: do not open-code __errno_location() callDenys Vlasenko2020-10-011-1/+6
| | | | | | | | | | | | Thanks dalias! Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: extend "errno pointer" trick to other than __GLIBC__Denys Vlasenko2020-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Savings on musl: function old new delta resume_main 582 614 +32 lbb_prepare - 20 +20 seq_main 432 449 +17 fgetsetversion 74 88 +14 ... script_main 1207 1180 -27 close_silently 28 - -28 shell_builtin_ulimit 655 626 -29 lineedit_read_key 280 247 -33 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 25/123 up/down: 182/-882) Total: -700 bytes text data bss dec hex filename 1005858 551 5676 1012085 f7175 busybox_old 1005136 551 5680 1011367 f6ea7 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | busybox: create custom installation directoryRon Yorston2020-08-151-5/+6
| | | | | | | | | | If a custom installation directory is specified try to create it. Don't worry if we can't, we'll find out when the links fail.
* | busybox: add option to install to Unix-style pathsRon Yorston2020-08-141-11/+34
| | | | | | | | | | The command 'busybox --install -u' installs links to Unix-style paths in the system drive.
* | Merge branch 'busybox' into mergeRon Yorston2020-07-091-5/+33
|\|
| * nologin: make it possible to build it as single appletDenys Vlasenko2020-06-241-5/+33
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: enable globbing by defaultRon Yorston2020-06-141-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change how busybox.exe expands wildcards on the command line. When globbing is enabled at compile time provide an implementation of _setargv(), which is run early during startup of C programs. This: - enables globbing by setting _dowildcard to -1 - checks for the presence of the environment BB_GLOBBING - if it exists and is set to 0 disables globbing - if it doesn't exist sets BB_GLOBBING=0 but continues to apply Windows' globbing in the current process The consequences of this are: - When busybox.exe is initially run from a Command Prompt Windows' globbing is applied; - Windows' globbing is turned off for future child processes, thus allowing the shell re-execute busybox.exe without it interfering with wildcards; - this behaviour can be overridden by setting BB_GLOBBING explicitly. Globbing can still be disabled at compile time if required. In that case BB_GLOBBING has no effect. With these changes globbing can be enabled by default and BusyBox will do the right thing in most circumstances. (See GitHub issues #172 and #189.)
* | ash: treat all applets as NOEXECRon Yorston2020-06-091-0/+3
| | | | | | | | | | | | | | | | | | In standalone shell mode tryexec() treats all applets as NOEXEC. Except for the shell: calling ash_main() recursively seems unwise. This avoids creating a new process for the applet (which is a Good Thing on Microsoft Windows where creating processes is expensive) but leaves the resources used by the invoking shell in the current process.
* | win32: only initialise networking if necessaryRon Yorston2020-06-011-4/+0
| | | | | | | | | | | | A call to initialise networking is made during start up even if the applet doesn't need it. Instead, only initialise networking when a call is made to a function that definitely requires it.
* | libbb: rearrange command line processingRon Yorston2020-04-051-13/+11
| | | | | | | | Process the '--busybox' flag before checking argv[0].
* | Merge branch 'busybox' into mergeRon Yorston2020-01-081-1/+1
|\|
| * clang/llvm 9 fix - do not eliminate a store to a fake "const"Denys Vlasenko2019-10-251-1/+1
| | | | | | | | | | | | | | This is *much* better (9 kbytes better) than dropping "*const" optimization trick. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Update copyright dateRon Yorston2020-01-081-1/+1
| |
* | Merge branch 'busybox' into mergeRon Yorston2019-08-161-5/+5
|\|
| * libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>