| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since commit 9e2a5668f (ash,hush: allow builtins to be tab-completed,
closes 7532) ash and hush have supported tab completion of builtins.
Other shells, bash and ksh for example, also support tab completion
of functions and aliases.
Add such support to ash and hush.
function old new delta
ash_command_name - 92 +92
hush_command_name - 63 +63
ash_builtin_name 17 - -17
hush_builtin_name 38 - -38
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/0 up/down: 169/-55) Total: 100 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Avi Halachmi <avihpit@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 950b318a2 (ash: Unix-style paths, shell builtins and applets)
broke running of Unix-style absolute paths from the shell by PATH
search. The copy of the program name on the stack should only be
used in the first call to tryexec() otherwise it interferes with the
use of the stack by padvance().
Also, bring the code to handle Unix-style paths in find_command()
into line with the revised code in shellexec().
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
getjob 281 285 +4
prefix 13 - -13
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 4/-13) Total: -9 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
changepath 67 68 +1
legal_pathopt 70 66 -4
prefix 34 13 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-25) Total: -24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We can just clear mailtime_hash to zero and have the same effect.
function old new delta
changemail 8 11 +3
mail_var_path_changed 1 - -1
cmdloop 398 382 -16
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 3/-17) Total: -14 bytes
text data bss dec hex filename
1054786 559 5020 1060365 102e0d busybox_old
1054773 559 5020 1060352 102e00 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
padvance() exit condition is return value < 0, not == 0.
After MAIL changing twice, the logic erroneously
concluded that "you have new mail".
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Mea culpa, in "Do not allocate stack string in padvance" commit
(I left an extraneous "break" statement).
function old new delta
cmdloop 329 398 +69
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
describe_command 323 320 -3
dotcmd 324 309 -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The trap and jobs builtins can be used to report information about
traps and jobs. This works when they're called from the current
shell but in a child shell the required information is usually
cleared. Special hacks allow:
- trap to work with command substitution;
- jobs to work with command substitution or in a pipeline.
Neither works with process substitution.
- Relax the test for the trap hack so it also supports pipelines.
- Pass the command to be evaluated to forkshell() in evalbackcmd()
so trap and jobs both work with process substitution.
function old new delta
forkchild 629 640 +11
argstr 1502 1496 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 11/-6) Total: 5 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 1d37186fe2 (ash: add bash-compatible EPOCH variables) added
support for the EPOCHSECONDS and EPOCHREALTIME variables.
These variables are dynamic and therefore require the VDYNAMIC flag
to be non-zero. However, this is only the case if support for the
RANDOM variable is enabled.
Give VDYNAMIC a non-zero value if either EPOCH variables or RANDOM
are enabled.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
No further problems with CRLF handling have been reported. Remove
the configuration option that allowed some recent changes to be
turned off.
Also, prevent some WIN32 code from being included in the POSIX
build. The faulty code is from commit 64c8f5f3d (ash: add support
for INT trap).
These changes don't alter the default WIN32 build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When INT is being trapped the read builtin gets special treatment
in bash. In a top-level interactive shell interrupting the read
with Ctrl-C clears the input and allows the user to enter a new
string. In a subshell Ctrl-C really does interrupt the read and
the trap isn't executed.
zsh works similarly, except that in the latter case the trap is
executed.
dash interrupts the read and executes the trap in both cases.
ksh also interrupts the read in both cases but only executes the
trap in the first.
Implement the bash behaviour.
(GitHub issue #303)
|
| |
| |
| |
| |
| | |
Reinstate the change introduced in commit 96c104a61c (ash: try harder
to avoid ctrl-c issue). It was removed during recent work on traps.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The trap builtin now handles INT. As before, other signals (from
a limited list) are accepted but their traps don't have any effect.
There's some variability in how shells handle traps. This patch
upholds that proud tradition.
Various changes are needed to make this work:
- Line editing has a new flag to ignore Ctrl-C.
- If INT is being trapped or ignored don't call raise_interrupt().
- A minimal implementation of dotrap() is provided.
- Call dotrap() when the read builtin or line input detect Ctrl-C.
- Adjust Ctrl-C detection when the INT trap is changed.
- Set may_have_traps when an INT trap is set.
Costs 368-448 bytes.
(GitHub issue #303)
|
| |
| |
| |
| |
| |
| | |
Commit 950b318a2 (ash: Unix-style paths, shell builtins and applets)
added a call to stack_add_ext_space() which should only be included
when building for Microsoft Windows.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Some shell builtins also exist as applets: echo, printf, pwd and
test, for example. If such an applet is referenced using a Unix-
style path, e.g. /usr/bin/echo, the applet should be run rather
than the builtin. Instead the current code says:
sh: /usr/bin/echo: file not found
Rearrange the tests in shellexec() so the correct behaviour occurs.
Actually, the error message was also incorrect due to a separate
bug. Commit d71cb67ff (win32: revert special treatment of Unix-style
absolute paths) failed to allocate space on the stack so that the
command passed to tryexec() could have an extension added if
required.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When a spawn_forkshell() was required in evalsubshell() two calls
to expredir() were being made: one in the parent and one in the
child. Rearrange the code so there's only one call, in the child.
The call to expredir() in the child is necessary because copynode()
doesn't take a copy of expfname in the nfile node. Code could be
added to do this but it's cheaper to call expredir().
Add code in forkshell_evalsubshell() to turn off the EV_TESTED
flag for background processes. I haven't found a case where this
makes a difference but no doubt somebody would have eventually.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Some environment variables are subject to special treatment: USER,
LOGNAME, HOME and SHELL are initialised when the shell starts if
they don't already have a value.
Some adjustments are necessary when changing privilege level:
- USERNAME is added to the set of variables subject to special
treatment. Unlike the others this is normally set on Windows.
- The special variables are now also updated on shell start up if
the current process is running with elevated privileges. This is
necessary so USER, USERNAME and LOGNAME have the correct value.
- USER, USERNAME and LOGNAME are set to the name of the unprivileged
user when elevated privileges are dropped, though not if they've
been changed from the expected value of "root".
Costs 160-208 bytes.
(GitHub issue #300)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add the environment variable BB_TERMINAL_MODE as a more general way
of controlling console/terminal mode setting. The default remains
unchanged: use virtual terminal mode for output if possible but
fall back to the console API with emulated ANSI escape sequences.
Currently valid settings are:
0 Force use of console mode
1 Force use of virtual terminal mode for output
5 Prefer virtual terminal mode for output, fall back to console
Other values won't do anything useful until code elsewhere has been
updated.
BB_SKIP_ANSI_EMULATION remains available for backwards compatibility.
If both variables are set BB_TERMINAL_MODE takes precedence.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As noted in commit 2d848eba5 (ash: fix CRLF handling), removing
CRs from CRLF pairs in preadbuffer() is complicated by the
possibility that a CRLF pair might be split across the boundary
between buffers.
Add a wrapper around calls to nonblock_immune_read() to allow for
this.
Adds 104-128 bytes.
(GitHub issue #280)
|
| |
| |
| |
| |
| |
| |
| | |
Commit 4b894b60a doesn't seem to have worked out. Revert it and
the fix in 6e0a6b7e5.
We're now back to removing CRs unconditionally from shell scripts.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 329f907b2 (ash: only reset ANSI emulation in interactive
loop) claimed to move resetting of ANSI emulation up into the
main interactive loop. Unfortunately it *just* missed the if-block
for interactive mode.
Put the call to skip_ansi_emulation() in the right place.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 54d2ea4b4 (ash: reset ANSI emulation at prompt) worked
around a problem with MSYS2 applications. This seems to have
been fixed in more recent versions of MSYS2 but there's still
value in retaining the workaround for other such cases.
However, the call to reset ANSI emulation is probably being made
more often than necessary. Move it out of setprompt_if() and into
the main shell interactive loop.
|
| |
| |
| |
| |
| |
| | |
The change introduced by commit 4b894b60a (ash: change CRLF handling)
failed to detect the end of a here document with a CRLF line ending.
Add the necessary check.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
record_pending_signo 32 63 +31
lineedit_read_key 231 224 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-7) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit e371e46fa0 (shell: add \r to IFS) added '\r' to the IFS
variable so field splitting would remove carriage returns.
Rather than change IFS, remove CRs preceding LFs in regions
being scanned for field splitting before IFS is applied. This
prevents free-standing CRs from being removed.
Costs 112-120 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As noted in commit 2d848eba5 (ash: fix CRLF handling) all CRs are
removed when scripts are read. Allow an alternative approach
(configurable at build-time, enabled by default):
- Do not strip CRs from input.
- Treat CR as similar to space or tab in base syntax mode.
- Adjust pgetc_eatbnl() to handle backslash-CRLF in the same way
as backslash-LF.
With these changes scripts containing CRLF line endings are more
likely to work.
Adds 48-56 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| | |
A misplaced #endif in ash and the wrong sense of a test in
parse_config.c broke the POSIX build.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Only remove CRs that are part of a CRLF pair in the output of
command substitution.
It would be nice to do the same in preadbuffer() but there's a
small chance the CRLF might be split between buffers.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The busybox-w32 shell initialises HOME when it starts. However,
if applets are run outside the environment provided by the shell
they may find HOME is unset. This caused a problem for 'vi' as
it was unable to locate its .exrc.
If HOME isn't available in the environment make getenv(3) provide
a sensible default value. The shell must use the *real* getenv(3)
when determining if HOME is already set.
Also, unrelated to the above, the shell shouldn't treat failure of
getpwuid(3) as a fatal error.
Costs 72-80 bytes.
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 605972390 (win32: handle Unix-style absolute paths for
executables) added special treatment of paths for executables
starting with a slash. Such paths are absolute on Unix but are
relative to the current drive on Windows. On reflection this
commit did more than necessary. Later commits provided special
treatment only for paths starting with locations traditionally
used to contain binaries on Unix. This is probably sufficient.
Problems introduced by commit 605972390 include:
- If the current drive isn't the system drive tab completion of a
command starting with a slash confusingly references the system
drive.
- Building busybox-w32 with w64devkit fails on drives other than
the system drive.
Revert the changes introduced by commit 605972390.
This saves 192 bytes.
(GitHub issue #239)
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
sleepcmd - 10 +10
builtintab 352 360 +8
.rodata 105264 105271 +7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 25/0) Total: 25 bytes
Signed-off-by: Shawn Landden <shawnlandden@tutanota.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
subevalvar 1566 1564 -2
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Patch by soeren@soeren-tempel.net
The idx variable points to a value in the stack string (as managed
by STPUTC). STPUTC may resize this stack string via realloc(3). If
this happens, the idx pointer needs to be updated. Otherwise,
dereferencing idx may result in a use-after free.
function old new delta
subevalvar 1562 1566 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Patch by Alex Gorinson <algore3698@gmail.com>
function old new delta
evalvar 477 495 +18
varvalue 603 618 +15
subevalvar 1557 1572 +15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 48/0) Total: 48 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ash and hush correctly use the value of HOME for tilde expansion.
However the line editing code in libbb obtains the user's home
directory by calling getpwuid(). Thus tildes in tab completion
and prompts may be interpreted differently than in tilde expansion.
When the line editing code is invoked from a shell make it use the
shell's interpretation of tilde. This is similar to how GNU readline
and bash collaborate.
function old new delta
get_homedir_or_NULL 29 72 +43
optschanged 119 126 +7
hush_main 1204 1211 +7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 57/0) Total: 57 bytes
v2: Always check for HOME before trying the password database: this
is what GNU readline does.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 6f8b2f450 (ash: forkshell code shrink) noted that certain
global variables were being passed around in the forkshell structure
unnecessarily.
In fact, since the variables are global there's no need to pass
them to the *_size()/*_copy() functions at all. This only saves
32 bytes of bloat (the compiler got there ahead of us) but it does
make the code tidier.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 3194a475d (ash: export certain variables to the environment
immediately) caused the special variables BB_OVERRIDE_APPLETS,
BB_SKIP_ANSI_EMULATION and BB_SYSTEMROOT to be exported to the
environment.
If one of these variables is replaced by a local variable its
previous value should be re-exported on leaving the local context
(function or simple command).
(GitHub issue #256)
|
| |
| |
| |
| |
| | |
Changing one of the constants used by is_bb_var() saves a few bytes
in the 32-bit build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit f9b753e70 (ash: set current working directory on startup)
set the current working directory of an interactive, non-login
shell during startup to ensure drives mapped to a network share
and symlinks were reported correctly.
It had the side effect of setting OLDPWD. This is unnecessary
because the current working directory won't have changed.
(GitHub issue #253)
|