| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Setting PS1 to:
PS1='$((123+))'
causes the shell to enter an infinite error loop:
sh: arithmetic syntax error
Catch any exception raised by expandarg() in expandstr() and allow
processing to continue.
function old new delta
expandstr 262 344 +82
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 82/0) Total: 82 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Setting PS1 to:
PS1='`xxx(`'
causes the shell to terminate with the error:
sh: syntax error: unexpected end of file (expecting ")")
This happens because old-style backquotes require the input to be reread
and thus call setinputstring() a second time. Prevent the problem by
unwinding all recently opened files in expandstr().
function old new delta
unwindfiles - 22 +22
expandstr 247 262 +15
forkchild 631 625 -6
evalcommand 1694 1685 -9
ash_main 1346 1336 -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 37/-25) Total: 12 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float. These are useful for logging or tracing.
function old new delta
change_epoch - 78 +78
.rodata 175167 175235 +68
varinit_data 264 312 +48
change_seconds - 24 +24
change_realtime - 24 +24
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/0 up/down: 242/0) Total: 242 bytes
text data bss dec hex filename
938508 4203 1888 944599 e69d7 busybox_old
938702 4203 1888 944793 e6a99 busybox_unstripped
v2: Cast tv_sec and tv_usec to unsigned quantities.
Add brackets to macros.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit b28d4c346 (ash: [VAR] Move unsetvar functionality into setvareq)
dropped the code that caused dynamic variables to lose their special
properties when unset. Add it back again.
function old new delta
setvareq 346 360 +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0) Total: 14 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
which return the number of seconds since the Unix Epoch as an
integer or float. These are useful for logging or tracing.
function old new delta
get_local_var_value 207 302 +95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 95/0) Total: 95 bytes
text data bss dec hex filename
938702 4203 1888 944793 e6a99 busybox_old
938797 4203 1888 944888 e6af8 busybox_unstripped
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Add a specific define to indicate which bash compatibility code
implements 'wait -n'.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Standardise the path names used for the current working directory by:
- resolving with realpath(3);
- making the drive name or host name uppercase.
The first only really works for physical drives; results for mapped
drives are patchy.
The standardisation is applied in two places:
- at the end of updatepwd() in ash;
- when a symbolic link is resolved in mingw_chdir().
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When a drive is mapped to a network share or a path display the
mapping in the 'Filesystem' column of df's output.
Since this changes the mnt_fsname field of the mntent structure
a slight alteration is needed to print_all_cwd() in ash.
Revert the change in commit a8c63f25b that enabled FEATURE_DF_FANCY
in the default configuration. None of the additional options is
very useful.
See GitHub issue #164.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
checkjobs 163 183 +20
process_wait_result 449 463 +14
leave_var_nest_level 98 107 +9
enter_var_nest_level 32 38 +6
set_vars_and_save_old 147 150 +3
builtin_local 53 56 +3
builtin_wait 322 323 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 56/0) Total: 56 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
waitcmd 205 288 +83
dowait 405 444 +39
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 122/0) Total: 122 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Microsoft Windows permits path names of the form 'c:path', without a
path separator after the colon. The system records a current directory
for each drive and the path is interpreted relative to that.
Since Windows API calls understand 'c:path' path names many commands
in busybox-w32 already work with them. This commit adds the following:
- The 'cd' shell built-in interprets 'c:path' path names correctly.
Previously it treated them as relative to the shell's concept of
the current working directory, not the current directory of the
specified drive.
- The 'pwd' shell built-in takes the '-a' option to list the current
directory for all drives.
- 'c:path' path names are subject to tab-completion.
Paths of the form 'c:path' don't work for mapped network drives or
paths that have been associated with a drive using SUBST.
See GitHub issue #147.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
BusyBox contains hardcoded references to absolute paths which
are unique in the *nix world but on Microsoft Windows are
interpreted as being on the current drive. To make these unique
again consider them to be relative to %SYSTEMDRIVE%.
Support this by adding functions to:
- determine the system drive (not using the environment variable);
- change a process's current directory to the root of the system drive;
- make relative paths absolute before changing directory (if needed).
The following applications have been modified:
- ash references /etc/profile from the system drive;
- dpkg places its data store on and installs files to the system drive;
- rpm installs files to the system drive;
- man looks for configuration files and man pages on the system drive.
See GitHub issue #158.
|
| |
| |
| |
| |
| |
| |
| | |
Move unc_root_len() from ash to mingw32.c and use it in the new
function root_len(), which can be used in make_directory().
This reduces changes to upstream code and saves a few bytes.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit a23624237 (win32: special treatment for PATH) required the
PATH variable to use ';' as the separator between components and
enforced this by intercepting attempts to update it.
Do the same for the CDPATH and MANPATH variables.
Also, fix a case in cdcmd() where the wrong separator was used.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the shell starts behave as though the user had manually changed
to the current working directory of the process, but only if it's an
interactive, non-login shell and the '-d' flag isn't present.
This gives more consistent behaviour when the shell is started in a
drive mapped to a network share or a symlinked directory.
This completes the changes requested in GitHub issue #148.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There are now two places where slashes are converted to backslashes
throughout a string so it makes sense to create a function to do
this.
To avoid confusion rename convert_slashes() to bs_to_slash() and
call the new function slash_to_bs().
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The following constructs result in ever-increasing memory usage:
while true; do { true; } </dev/null; done
while true; do ( true; ) </dev/null; done
For comparison, bash displays static memory usage in both cases.
This has been fixed in dash by commit 2bc6caa. The maintainer
writes:
I have simplified evaltree so that it simply sets the stack mark
unconditionally. This allows us to remove the stack marks in the
functions called by evaltree.
Closes BusyBox bug 7748.
function old new delta
evaltree 606 632 +26
evalcommand 1724 1696 -28
evalcase 382 351 -31
evalfor 230 196 -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 26/-93) Total: -67 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Rework the code in updatepwd() which processes UNC paths so that
the root of a share is properly identified. This fixes problems
when:
- the current directory is a share and the user changes to '/';
- the current directory is the root of a share and the user tries
to change to '..'.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Formalise the use of 0 as the uid of a process running with elevated
privileges:
- Rewrite getuid(2) to return DEFAULT_UID by default and 0 if the
process has elevated privileges.
- geteuid(2) and the corresponding functions for groups are aliases
for getuid(2).
- Change root's home directory to be whatever GetSystemDirectory()
returns, probably C:/Windows/System32 in most cases.
- Remove the special handling of geteuid(2) in the line editing code.
With these changes the shell started by 'su' is a lot more like a
*nix root shell.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
When busybox-w32 is installed in C:/Windows/System32 su doesn't
run in the same directory as its parent as intended.
Work around this by adding a flag to the shell to set the working
directory.
|
| |
| |
| |
| |
| | |
The 'nocaseglob' shell option enables case-insensitive filename
globbing. By default globbing is case-sensitive.
|
| |
| |
| |
| |
| |
| | |
There were a few places where changes intended for the WIN32 build
also affected the POSIX build. Fix these so the result of 'make
defconfig; make' for busybox-w32 is identical to upstream BusyBox.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Move the code to hide the console to a separate function in
win32/mingw.c. Use lazy loading to avoid problems on platforms
where the require APIs aren't supported (PR #70).
Enable console hiding in the default 64-bit configuration.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Instead of always returning that no input is available:
- for a disk file return 'available';
- for the console return 'not available';
- for anything else (e.g. pipe) return whatever poll says.
This fixes the test ash-read/read_t0.tests.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
These are cosmetic changes only.
Make the arguments to spawn_forkshell more like those of forkshell.
Since job control isn't currently supported in busybox-w32 the node
argument isn't actually used.
The node passed in the forkshell structure is used in the child
code. It may be different from the node passed as an argument to
spawn_forkshell which, in the upstream code, is forwarded to
forkparent and forkchild.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The euro currency symbol was added to some OEM code pages. See:
https://www.aivosto.com/articles/charsets-codepages-dos.html
Add a configuration option (enabled by default) to support this.
When enabled:
- The read_key() function requests wide character key events. This
allows the euro symbol to be entered regardless of the console OEM
code page, though it needs to be available in the ANSI code page.
- Conversions between OEM and ANSI code pages in winansi.c are
modified to work around a bug in the Microsoft routines.
- If the OEM code page is 850 when BusyBox starts it's changed to
858. This is the only currently supported OEM code page.
Also, the shell read builtin is modified to use read_key() whenever
input is being taken from the console.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The shell could fail to evaluate strings containing carriage
returns. For example:
awk 'BEGIN {
"set -ex\r\npwd\r\n" | getline
}' </dev/null
The string is passed as an argument to "sh -c". The "set" built-in
fails because it attempts to treat the carriage return as an option.
Although this is correct behaviour on Unix it may be unhelpful on
Microsoft Windows.
See GitHub issue #138.
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
sigprocmask2 - 8 +8
wait_for_child_or_signal 213 218 +5
dowait 424 429 +5
block_CHLD_HUP_ALRM 62 59 -3
sigprocmask_SIG_SETMASK 16 - -16
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/1 up/down: 18/-19) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
sigprocmask_SIG_SETMASK - 16 +16
wait_for_child_or_signal 221 213 -8
dowait 432 424 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Implement read_cmdline() for WIN32 by storing the command line in
the same way as the applet name.
The applet name is actually used for the comm column which is
truncated to COMM_LEN. Using this as the size of the bb_comm
array avoids the need to calculate MAX_APPLET_NAME_LEN.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
umask() in the Microsoft C runtime takes different arguments to
umask(2). Implement a fake umask(2) that remembers the mask and
calls the Microsoft umask() with an appropriate value.
Since the mask won't be inherited by children use an environment
variable to pass any value set by the shell built-in umask.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The previous commit included code to use PATH values assigned to
local variables:
PATH=/new/path:$PATH new_binary
It didn't work in the case when no fork was needed, for example:
(PATH=/new/path:$PATH new_binary)
because the call to listsetvar() freed the PATH value that was
passed to shellexec(). The forking case only worked because the
spawn_forkshell() mechanism in busybox-w32 didn't allow the PATH
value to be freed.
Rewrite the code so it works whether or not a fork is needed. The
code would also work on POSIX systems.
A cleaner solution could be extracted from dash commit cbb71a8
'eval: Add assignment built-in support again' but neither that nor
the current patch are suitable for submission to upstream BusyBox.
This one is preferred because it requires fewer changes from
upstream.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The PATH shell variable is a special case. It can be exported to
the environment where it might be interpreted by native applications
which assume the separator is ';'. Hence:
- require that the separator used in PATH is ';'
- enforce this by intercepting calls to setvareq() that set PATH
and adjusting its value if necessary.
As a result of this the code to parse PATH can be simplified by
replacing the hardcoded Unix ':' path separator by the platform-
dependent macro PATH_SEP.
The MANPATH variable is also required to use ';' as its separator
but since it's less likely to be used this isn't enforced.
|
| |
| |
| |
| |
| |
| |
| | |
ash calls setup_environment() but only uses a small amount of its
functionality. Moving the code into ash itself means we don't
need to customise setup_environment() for WIN32 and can remove
it from the build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
spawn_forkshell() was missing some code that would normally have
been run from forkchild when a background process was started:
- the ctrl-c handler wasn't disabled;
- standard input wasn't connected to /dev/null.
Using ctrl-c to kill a foreground process also killed background
processes.
Fixing this requires passing the forkshell mode and the number of
processes associated with the forkshell job to the child process.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
There were two flaws in the implementation of ctrl-c handling in
waitpid_child():
- processes associated with all jobs were killed;
- all processes in a pipeline were killed but only the status of
one was updated.
As a result of the latter ctrl-c didn't reliably stop a pipeline.
|