| 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>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
builtin_set 258 301 +43
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
hush_main 1815 1851 +36
re_execute_shell 601 635 +34
.rodata 102721 102726 +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 75/0) Total: 75 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
hush_main 1810 1815 +5
.rodata 102723 102721 -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 5/-2) Total: 3 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Disable ENABLE_PROCESSED_INPUT in raw mode. Otherwise ^C isn't
immediately detected during shell command line editing with
virtual terminal input enabled.
- Switch read_key()/unix_readkey() to windows_read_key()/read_key().
This allows the shell `read` builtin to use windows_read_key().
Without this change `read` fails when virtual terminal input is
enabled.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 0eda390d6 (ash: improve handling of 'read -t 0') added code
to work around the limitations of our poll(2) implementation.
Now that poll(2) has been improved the workaround is unnecessary.
Saves 64 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
check_and_run_traps 229 278 +49
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Found one case where SIGHUP does need some handling.
ash does not restore tty pgrp when killed by SIGHUP, and
this means process which started ash needs to restore it,
or it would get backgrounded when trying to use tty.
function old new delta
check_and_run_traps 214 229 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Kernel should do the right thing.
(ash and dash do not have special SIGHUP handling.)
function old new delta
check_and_run_traps 278 214 -64
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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 deae0c7bf3 (Skip carriage return in read builtin command)
caused all CRs to be removed from input to the read builtin.
Only remove CRs that are part of a CRLF pair.
Adds 64-80 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
run_list 1032 1012 -20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
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)
|
|\| |
|