| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
POSIX generally requires normal output to go to stdout and
diagnostic (i.e. error) output to go to stderr.
When usage messages for BusyBox applets are specifically requested
by the user (e.g. 'find --help') they should go to stdout; when
they're emitted due to an error they should go to stderr.
function old new delta
bb_show_usage 148 146 -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-2) Total: -2 bytes
Signed-off-by: Avi Halachmi <avihpit@yahoo.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There are two calls to dup2() in busybox_main(). These were
introduced to coerce full_write2_str() into writing to stdout.
The relevant commits were: 21278dff7 (busybox: do not print help
to fd 2, print it to fd 1) and 5a7c72015 (busybox --list option.
+140 bytes. Rob wanted it.)
Later, in commit 729ecb87b (bbconfig: make it independent from
printf functions), the function full_write1_str() was added.
Using this in busybox_main() allows us to drop the dup2() calls.
function old new delta
run_applet_and_exit 796 760 -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-36) Total: -36 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 4b7b4a960 (ash: optimise running of scripts) avoided creation
of a process when running a script. There's another case where we
can do the same: if the script is being run from a FS_SHELLEXEC
shell.
- Check the necessary conditions for this to happen.
- Allocate two extra slots in the argv array for FS_SHELLEXEC.
- Set the index of the script file in the argv array. Without this
the test 'pidof this' failed because the command name hadn't been
correctly set.
Adds 80-96 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A previous commit (e3bfe3695) revised the use of getsysdir() to
obtain the system directory, and hence the system drive. See the
commit message for the history to that point.
Further improvements are possible:
- Remove getsysdir() and push the calls to GetSystemDirectory()
down into get_system_drive() and get_proc_addr().
- Check the return value of GetSystemDirectory(). It's unlikely
to fail, but better safe than sorry.
- Instead of making all callers of get_system_drive() check for a
NULL return value always return a non-NULL pointer. If the drive
can't be found an empty string is returned instead (which is what
the callers were using anyway).
- The function need_system_drive() was only used in one place (in
httpd). Move the code there and remove the function.
- Use concat_path_file() where possible.
Saves 76-144 bytes.
|
| |
| |
| |
| |
| |
| | |
Rewrite the test for the value of BB_CRITICAL_ERROR_DIALOGS.
Saves 16-48 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the environment variable BB_CRITICAL_ERROR_DIALOGS is set to
1 critical error dialogs are enabled. If unset or set to any
other value they aren't. In either case the error messages
introduced by commit 790e37727 (win32: revert 'don't set error
mode') are issued.
The shell exports BB_CRITICAL_ERROR_DIALOGS to the environment
immediately on any change so the setting takes effect at once.
Adds 104-160 bytes.
(GitHub issue #423)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit eb376b5d1 (win32: don't set error mode) removed a call to
SetErrorMode(SEM_FAILCRITICALERRORS).
But the documentation says:
Best practice is that all applications call the process-wide
SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS
at startup. This is to prevent error mode dialogs from hanging
the application.
Doing this prevents the system from displaying useful information,
though. The application should attempt to tell the user what went
wrong.
Reinstate the call to SetErrorMode() and try to provide an error
message, at least for the situation mentioned in issue #423 and
other similar cases.
Adds 360-368 bytes.
(GitHub issue #423)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit a8c63f25b3 (win32: improve filesystem detection and display)
added a call to SetErrorMode(SEM_FAILCRITICALERRORS). This was
on the strength of the documentation for GetVolumeInformation()
which suggests that otherwise a message box will appear to prompt
the user to put media in an empty floppy or CD drive. This would
disrupt the expected behaviour of applets like 'df'.
In practice it seems the call to SetErrorMode() is unnecessary.
It also results in other errors going unreported.
Remove the call to SetErrorMode().
Saves 8-20 bytes.
(GitHub issue #423)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
(GitHub issue #422)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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.
|
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| | |
This doesn't affect the generated binary, at least in the default
configuration.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| | |
When the UTF-8 manifest is included in the binary but the ANSI
code page isn't UTF-8 report "UTF8 manifest not supported".
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
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+).
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
|\| |
|
| |
| |
| |
| |
| | |
Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
|\| |
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
show_usage_if_dash_dash_help 72 79 +7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 conflicts in reset and ash.
Redefine the new safe_read_key() as a reference to read_key().
Disable SHA256_HWACCEL.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| | |
- 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>
|
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| | |
Upstream has fixed a problem with 'busybox --help' so it's
possible to remove another gratuitous divergence.
|
| |
| |
| |
| |
| | |
Upstream changes broke the 'busybox --help busybox' command.
Fix it.
|