| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
parse_stream 2271 2292 +21
.rodata 105408 105427 +19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
set_G_ifs - 151 +151
run_list 1024 1031 +7
run_pipe 1567 1445 -122
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 158/-122) Total: 36 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The Cygwin terminal program mintty sets the HOME environment
variable. Attempt to detect this and unset HOME so the usual
busybox-w32 initialisation of HOME is used instead.
Adds 80 bytes.
(GitHub issue #420)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When a shell was started with the -X option, environment variables
had forward slashes changed to backslashes. This is unnecessary
and counterproductive.
Adjust how the state of winxp is handled to avoid this.
(GitHub issue #415)
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
An alias expansion immediately followed by '&' is parsed
incorrectly:
~ $ alias x='sleep 2'
~ $ x&
~ $
sh: syntax error: unexpected "&"
The sleep happens in the foreground and the '&' is left in the
input buffer. The same problem occurs in upstream BusyBox but
not dash.
The difference between BusyBox and dash is that BusyBox supports
bash-style output redirection (BASH_REDIR_OUTPUT in the code).
This requires checking for '&>' in readtoken1().
When the end of the alias is found, the '&' and the following
newline are both read to check for '&>'. Since there's no match
both characters are pushed back.
The alias is then expanded and __pgetc() is called to fetch the
next character. Since there are none left in the alias string
__pgetc() calls preadbuffer() which pops the string, reverts to
the previous input and recursively calls __pgetc(). This request
is satisified from the pungetc buffer. But the first __pgetc()
doesn't know this: it sees the character has come from
preadbuffer() so it (incorrectly) updates the pungetc buffer.
Resolve the issue by moving the code to pop the string and fetch
the next character up from preadbuffer() into __pgetc().
Saves 32-48 bytes.
(GitHub issue #413)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The 'noiconify' option controls how the console window is concealed
when the 'noconsole' option is used. The default is to iconify
the console. When 'noiconify' is 'on' the console is hidden.
Adds 8-16 bytes.
(GitHub issue #325)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 67ed7484be (ash: detect console state on shell start up)
synchronised the noconsole option with the actual state of the
window on shell start up.
This is insufficient. The user can change the state of the window
independently of the noconsole option, leading to confusion and
unwanted iconification of the window when unrelated 'set' commands
are issued.
Detect the current console state on every call to options().
Saves 16-32 bytes.
(GitHub issue #325)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Mixing Windows and Unix-style filename extensions was causing
problems. Tweak how extensions are handled to try and improve
matters:
- Consistently check whether the unaltered filename is an
executable before trying adding extensions.
- Check .exe and .com before .sh.
Saves up to 16 bytes.
(GitHub issue #405)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The undocumented '-d' shell option is used to set the current
directory in shells started by the 'su' applet of busybox-w32.
In this case, the shell isn't a login shell.
If a login shell sets the current working directory in /etc/profile
it's possible the user may wish to override this with '-d'. This
didn't work, though, because the directory is changed before
/etc/profile is processed.
Move the changing of the directory to that specified by '-d' so it
happens after the processing of /etc/profile and ~/.profile. This
won't affect the intended use of '-d'.
(GitHub issue #403)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Implement a 'title' built-in for ash. It's very simple-minded,
performs almost no error checking and is completely non-portable.
- With no arguments it prints the current console title.
- If arguments are provided the *first only* is set as the console
title.
Costs 88-116 bytes.
(GitHub issue #401)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 26ba73098 (win32: search PATH for missing Unix-style
executables) extended the cases in which PATH would be searched
for executables specified with a Unix-style path.
A side effect of this change was to pass the Unix-style path as
argv[0] to NOFORK applets. The 'uname' applet examines argv[0]
to determine how to behave. When invoked as '/bin/uname' it
returned unexpected results. Other applets may be similarly
affected.
When a NOFORK applet is invoked in evalcommand(), strip any path.
Costs 16 bytes.
(GitHub issue #392)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commits 8e6991733 and b2901ce8e fixed problems with the 'read'
shell built-in when the '-t' option was used. However, they
result in a performance penalty. This pipeline:
seq -w 0 999999 | while read line; do :; done
takes 10 times longer than prior to the changes.
If no timeout is specified don't call poll(2).
Costs 16 bytes in a 32-bit build; 0 in 64-bit.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit ea8742bc16 (ash: workaround environment issue in Windows
on ARM) prevented nofork applets from being run without a fork
in standalone shell mode in Windows on ARM. This was due to a
deficiency in the handling of the 'environ' global.
However, the problem is specific to MSVCRT. If the target is
UCRT nofork applets can be made to work without a fork.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
The environment is handled differently in ARM64 Windows.
Assignments to 'environ' result in a compiler error. Omit the
offending code for now. NOFORK applets will cause a fork.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Following on from commit c84b81ce4 (ash: reduce size of forkshell
relocation block):
- Store the flags to indicate if annotations should be freed in a
separate array. This only affects builds with forkshell debug
enabled.
- Use a bitmap to indicate which pointers need relocation (instead
of an array of bytes).
This reduces the size of the forkshell data block by a few hundred
bytes.
Adds 32-64 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The forkshell relocation block had one byte for each byte of the
forkshell structure and funcblock. It's only necessary to allow
one byte for each pointer. (One or two bits would be enough, but
would make the code more complex.)
The impact of this change depends on the data and whether the CPU
is 32- or 64-bit. It typically saves a few Kbytes.
Costs 16-52 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Remove a check that there are no relocations for addresses in the
funcstring block. At one point during development the relocation
block had entries for that area, but not any more.
This only affects non-default builds with forkshell debug enabled.
|
| |
| |
| |
| |
| |
| | |
Rearrange the handling of pointer relocation during forkshell and
add a couple of additional sanity checks. There's no functional
change to non-debug builds.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When a pipeline is created the parent allocates an array of procstat
structures sufficient for the number of members of the pipeline.
The child processes, however, only see the number of processes
created so far. Thus, the first child sees that a procstat array
has been created but contains no processes.
This resulted in an invalid pointer to the procstat array in the
first child. This probably doesn't matter: if the number of
processes is zero there should be no need to access the array.
Set the pointer to NULL so if it is accessed we'll know about it.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 7b692ddf0 (ash: improved support for jobs built-in) didn't
correctly initialise the pointer to the job table if it was empty.
This resulted in the following crashing:
sh -c "cat <(echo HelloWorld | rev)"
Fix forkshell_copy() so the job table pointer is NULL if there are
no jobs.
Adds 16 bytes.
(GitHub issue #379)
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add two utility functions to convert Windows process exit codes.
- exit_code_to_wait_status() converts to a POSIX wait status.
This is used in ash and the implementations of system(3) and
mingw_wait3().
- exit_code_to_posix() converts to a POSIX exit code. (Not that
POSIX has much to say about them.)
As a result it's possible for more applets to report when child
processes are killed as if by a signal. 'time', 'drop' and 'su -W',
for example.
Adds 64-80 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 89aa9d783 (win32: changes to signal handling) caused a
regression: 'httpd -f' could no longer be interrupted by Ctrl-C.
The specific issue is the use of exit(2) to replace raise(3) in
raise_interrupt(). This change was made so the shell would return
the expected exit code of 130 rather than the default code of 3
which Windows uses when a signal with SIG_DFL disposition is caught.
The problem can be avoided by calling _exit(2) instead. A call to
fflush_all() has also been added, as _exit(2) doesn't do that.
(GitHub issue #365)
|
| |
| |
| |
| |
| |
| | |
Upstream commit ed4a24dfd (ash: initialize basepf.buf in ash)
zeroes out the memory allocated for basepf.buf. busybox-w32 has
a copy of this code early in ash_main(). Do the same there.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When I planned to print the command in read_line_input, I found that after
the system started, the command printed for the first time was always
garbled.
After analysis, it is found that in the init() function of ash, the
variable basepf.buf is not initialized after applying for memory, resulting
in garbled initial data. Then assign it to the global variable
g_parsefile->buf in ash.c, and then pass g_parsefile->buf to the parameter
command of the function read_line_input in the function preadfd(), and
finally cause it to be garbled when the command is printed by
read_line_input.
The call stack is as follows:
#0 read_line_input (st=0xb6fff220, prompt=0xb6ffc910 "\\[\\033[32m\\]\\h \\w\\[\\033[m\\] \\$ ", command=command@entry=0xb6ffc230 "P\325\377\266P\325\377\266", maxsize=maxsize@entry=1024) at libbb/lineedit.c:2461
#1 0x0043ef8c in preadfd () at shell/ash.c:10812
#2 preadbuffer () at shell/ash.c:10914
#3 pgetc () at shell/ash.c:10997
#4 0x00440c20 in pgetc_eatbnl () at shell/ash.c:11039
#5 0x00440cbc in xxreadtoken () at shell/ash.c:13157
#6 0x00440f40 in readtoken () at shell/ash.c:13268
#7 0x00441234 in list (nlflag=nlflag@entry=1) at shell/ash.c:11782
#8 0x004420e8 in parsecmd (interact=<optimized out>) at shell/ash.c:13344
#9 0x00442c34 in cmdloop (top=top@entry=1) at shell/ash.c:13549
#10 0x00444e4c in ash_main (argc=<optimized out>, argv=0x444e4c <ash_main+1328>) at shell/ash.c:14747
#11 0x00407954 in run_applet_no_and_exit (applet_no=9, name=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1024
#12 0x00407b68 in run_applet_and_exit (name=0xbefffe56 "ash", argv=0x9) at libbb/appletlib.c:1047
#13 0x00407f88 in main (argc=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1181
Fixes: 82dd14a510ca ("ash: use CONFIG_FEATURE_EDITING_MAX_LEN")
Signed-off-by: zhuyan <zhuyan34@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Set 'noconsole' to match the actual state of the console (normal/
iconified) when the shell is started. Thus ShowWindow() will only
be called if the actual state differs from the default or user
defined state.
Costs 20-24 bytes.
(GitHub issue #325)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The shell detected a native Windows environment by checking for a
mixed-case 'Path' environment variable. This has always worked on
Windows but recent versions of Wine have a 'PATH' environment
variable.
Check also for 'ComSpec'.
Costs 24-48 bytes.
|
| |
| |
| |
| |
| |
| |
| | |
Make it possible to use the 'trap' built-in with command substitution,
process substitution and in pipelines.
Costs 200-256 bytes.
|
| |
| |
| |
| |
| |
| |
| | |
Move the code to handle the case nprocs == 1 from jobtab_size()
to procstat_size().
Saves 16 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Pass job data to child shells. This makes it possible to use
the 'jobs' built-in with command substitution, process substitution
and in pipelines.
Costs 576-672 bytes
(GitHub issue #350)
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
aliascmd 274 278 +4
signal_handler 81 80 -1
static.redirectsafe 144 141 -3
unwindlocalvars 219 215 -4
trapcmd 333 329 -4
setvar 164 160 -4
setpwd 167 163 -4
setinputfile 216 212 -4
setcmd 76 72 -4
readcmd 221 217 -4
raise_exception 26 22 -4
out2str 37 33 -4
out1str 32 28 -4
freejob 89 85 -4
forkchild 616 612 -4
fg_bgcmd 298 294 -4
expandarg 949 945 -4
evaltree 753 749 -4
evalsubshell 173 169 -4
evalpipe 346 342 -4
evalfun 408 404 -4
cdcmd 699 695 -4
ash_main 1240 1236 -4
__pgetc 589 585 -4
unaliascmd 152 147 -5
unalias 51 46 -5
umaskcmd 253 248 -5
stalloc 97 92 -5
shiftcmd 144 139 -5
setinputstring 73 68 -5
redirect 1068 1063 -5
recordregion 81 76 -5
pushstring 160 155 -5
popstring 120 115 -5
popstackmark 69 64 -5
popredir 123 118 -5
popfile 110 105 -5
out1fmt 45 40 -5
newline_and_flush 39 34 -5
ifsfree 66 61 -5
growstackblock 146 141 -5
freestrings 95 90 -5
fmtstr 59 54 -5
flush_stdout_stderr 23 18 -5
dowait 577 572 -5
delete_cmd_entry 52 47 -5
clearcmdentry 98 93 -5
ash_arith 79 74 -5
argstr 1404 1399 -5
evalcommand 1523 1515 -8
removerecordregions 219 209 -10
mklocal 284 274 -10
find_command 893 883 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/52 up/down: 4/-251) Total: -247 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Has a few annoying problems:
* sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell.
* sleep_for_duration() in sleep_main() has to be interruptible for
^C traps to work, which may be a problem for other users
of sleep_for_duration().
* BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it
as well (try "/bin/sleep 1 & sleep 10").
* sleep_main() must not allocate anything as ^C in ash longjmp's.
(currently, allocations are only on error paths, in message printing).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
.rodata 105304 105261 -43
parse_command 1696 1633 -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
builtin_readonly 61 107 +46
builtin_export 140 145 +5
.rodata 105321 105304 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 51/-17) Total: 34 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|