Commit Graph

2310 Commits

Author SHA1 Message Date
Denys Vlasenko
3f7fb2c89a ash: output: Fix fmtstr return value
Upstream commit:

    Date: Sat, 19 May 2018 02:39:44 +0800
    output: Fix fmtstr return value

    The function fmtstr is meant to return the actual length of output
    produced, rather than the untruncated length.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-16 19:14:45 +01:00
Denys Vlasenko
970470e235 ash: main: Only set savestatus in exitcmd
Upstream commit:

    Date: Sat, 19 May 2018 02:39:38 +0800
    main: Only set savestatus in exitcmd

    Currently exitcmd sets exitstatus and then savestatus if the latter
    was previously set.  In fact, as exitcmd always raises an exception
    and will either end up in the setjmp call in main() or exitshell(),
    where exitstatus is always replaced by savestatus if set, we only
    need to set savestatus.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-16 19:14:45 +01:00
Denys Vlasenko
4ccddc8fb3 ash: [BUILTIN] Exit without arguments in a trap should use status outside traps
Upstream commit:

    Date:   Mon Oct 6 10:39:47 2014 +0800
    [BUILTIN] Exit without arguments in a trap should use status outside traps

    POSIX now requires that exit without arguments in a trap should
    return the last command status prior to executing traps.  This
    patch implements this behaviour.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-16 19:14:45 +01:00
Denys Vlasenko
f7eea8c235 ash: parser: Fix incorrect eating of backslash newlines
Keeping up with upstream (in our case, 'before patch' code is not buggy).
Upstream commit:

    Date: Fri, 11 May 2018 23:41:25 +0800
    parser: Fix incorrect eating of backslash newlines

    With the introduction of synstack->syntax, a number of references
    to the syntax variable was missed during the conversion.  This
    causes backslash newlines to be incorrectly removed in single
    quote context.

    This patch also combines these calls into a new helper function
    pgetc_top.

    Fixes: ab1cecb40478 ("parser: Add syntax stack for recursive...")
    Reported-by: Leah Neukirchen <leah@vuxu.org>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-16 19:14:45 +01:00
Denys Vlasenko
acf79f9913 ash: use pgetc_eatbnl() in more places, take 2
Adding previously skipped "readtoken1(pgetc_eatbnl(), DQSYNTAX..." changes
from upstream commit:

    Date:   Thu Mar 8 08:37:11 2018 +0100
    Author: Harald van Dijk <harald@gigawatt.nl>
    parser: use pgetc_eatbnl() in more places

    dash has a pgetc_eatbnl function in parser.c which skips any
    backslash-newline combinations. It's not used everywhere it could be.
    There is also some duplicated backslash-newline handling elsewhere in
    parser.c. Replace most of the calls to pgetc() with calls to
    pgetc_eatbnl() and remove the duplicated backslash-newline handling.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-16 19:14:45 +01:00
Ron Yorston
9e2a5668fd ash,hush: allow builtins to be tab-completed, closes 7532
function                                             old     new   delta
complete_cmd_dir_file                                678     830    +152
get_builtin_name                                       -      35     +35
optschanged                                          125     132      +7
hush_main                                           1069    1076      +7
save_command_ps_at_cur_history                        76      78      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 203/0)             Total: 203 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-29 15:23:17 +01:00
Ron Yorston
b0c711e64f ash: improve expandstr()
The dash maintainer recently posted a fix for issues with expanding
PS1.  These had already been fixed differently in BusyBox ash.  Borrow
a couple of improvements:

- Use a single call to setjmp() to trap errors in both readtoken1()
  and expandarg().

- In case of error set the prompt to the literal value of PS1 rather
  than the half-digested nonsense in stackblock() which might include
  ugly control characters.

function                                             old     new   delta
expandstr                                            353     300     -53

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-29 13:59:45 +01:00
Denys Vlasenko
259747caa7 hush: fix preprocessor directives indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-28 10:28:14 +01:00
Denys Vlasenko
21806562ca hush: restore redirected stdin
function                                             old     new   delta
restore_redirects                                     52      95     +43
save_fd_on_redirect                                  243     253     +10
hfopen                                                90      99      +9
fgetc_interactive                                    259     261      +2
builtin_type                                         117     115      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 64/-2)              Total: 62 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-01 14:16:07 +01:00
Denys Vlasenko
af7169b4a7 clang/llvm 9 fix - do not eliminate a store to a fake "const"
This is *much* better (9 kbytes better) than dropping "*const"
optimization trick.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-25 12:12:22 +02:00
Denys Vlasenko
7427406580 shell: better comments in BASE#nn code
function                                             old     new   delta
evaluate_string                                      932     930      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-22 14:25:43 +02:00
Denys Vlasenko
3ef513e787 shell/ulimit: code shrink
text	   data	    bss	    dec	    hex	filename
1001949	    551	   5612	1008112	  f61f0	busybox_old
1001906	    551	   5612	1008069	  f61c5	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-21 16:47:09 +02:00
Denys Vlasenko
c58d785b9d ash: fix BASE###nn bashism for bases 36..64
function                                             old     new   delta
evaluate_string                                      876     932     +56

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-22 23:40:10 +02:00
Denys Vlasenko
ca1ce4b9fa ash: fix BASE###nn bashism to accept letter 'digits' for bases > 9
function                                             old     new   delta
evaluate_string                                      873     876      +3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-22 18:26:05 +02:00
Denys Vlasenko
35e349de3c ash: add a FIXME comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 14:31:49 +02:00
Denys Vlasenko
18a90ec846 hush: fix "set -o INVALID" affecting -e flag state
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05 14:07:14 +02:00
Denys Vlasenko
2f9c124f7d ash: fix set -o to not show "nameless" options
Patch by Martijn Dekker <martijn@inlv.org>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-08-02 16:44:35 +02:00
Ron Yorston
943e81f5db ash: only catch unexpected exceptions in PS1 expansion
Commit d1a2fa2a4 (ash: catch error in arithmetic expansion in PS1)
catches all exceptions raised by expandarg().  Some exceptions, such as
the EXEXIT raised when command expansion is used, are expected:

   export PS1='$(echo "$ ")'

These should be processed normally or the shell hangs at the prompt.

function                                             old     new   delta
expandstr                                            344     353      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-31 13:44:32 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
f3634584d0 ash,hush: show 'c' in $- if run in "sh -c CMD"
function                                             old     new   delta
options                                              552     599     +47
expand_one_var                                      2375    2385     +10
optletters_optnames                                   60      64      +4
hush_main                                           1108    1111      +3
ash_main                                            1150    1152      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 66/0)               Total: 66 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03 12:21:04 +02:00
Denys Vlasenko
897475ab02 ash: allocate line editing structure only if needed
function                                             old     new   delta
optschanged                                           91     128     +37
historycmd                                            13      17      +4
setcmd                                                80      78      -2
ash_main                                            1167    1150     -17
options                                              576     552     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 41/-43)             Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-01 16:35:09 +02:00
Denys Vlasenko
8b35f207bb shell: move all definitions of strto_arith_t() together
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26 14:02:10 +02:00
Denys Vlasenko
d8740b265a hush: show 's' in $-
function                                             old     new   delta
expand_one_var                                      2362    2375     +13
hush_main                                           1104    1108      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 17/0)               Total: 17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 19:11:21 +02:00
Denys Vlasenko
76a4e8361a hush: allocate line edit buffer only for interactive shell
function                                             old     new   delta
builtin_history                                       16      20      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 18:24:52 +02:00
Denys Vlasenko
9edd268bad shell: implement optional "BASE#nnnn" numeric literals
function                                             old     new   delta
evaluate_string                                      729     851    +122

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 17:23:31 +02:00
Denys Vlasenko
30a4c32a4d hush: remove test for "echo ${-}" errorring out - now it works
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 16:35:56 +02:00
Denys Vlasenko
ef8985c688 hush: implement $-, set default PATH if it is not set on startup
function                                             old     new   delta
expand_one_var                                      2311    2362     +51
hush_main                                           1075    1104     +29
parse_dollar                                         790     791      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 81/0)               Total: 81 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 16:29:09 +02:00
Denys Vlasenko
0c36019369 hush: set default PS1/2 only if we interactive
"env - hush SCRIPT" invocation (that is, with empty environment)
should not show PS1/2 in "set" output.

function                                             old     new   delta
hush_main                                           1070    1075      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 15:39:32 +02:00
Denys Vlasenko
08fb82c80c hush: handle LINENO the same way as RANDOM: variable is "ephemeral"
"env - hush" invocation (that is, with empty environment)
should not show LINENO in "set" output.

function                                             old     new   delta
get_local_var_value                                  263     294     +31
hush_main                                           1105    1070     -35
handle_changed_special_names                          79      38     -41
run_pipe                                            1834    1765     -69
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 31/-145)          Total: -114 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-19 15:39:32 +02:00
Denys Vlasenko
4ebcdf7396 hush: remove code to track PS1/2 values dynamically - it's too much work
Assignments / exports / unsets of variables are far more frequent than
prompt printing, and if we show prompt, we are likely to be limited by
user typing speed - do not optimize for that scenario.
Just re-query $PS1 / $PS2 values when need to show the prompt.

function                                             old     new   delta
fgetc_interactive                                    236     259     +23
set_vars_and_save_old                                150     147      -3
pseudo_exec_argv                                     597     594      -3
hush_main                                           1110    1105      -5
enter_var_nest_level                                  38      32      -6
builtin_local                                         56      50      -6
run_pipe                                            1857    1834     -23
leave_var_nest_level                                 127      98     -29
handle_changed_special_names                         111      79     -32
cmdedit_update_prompt                                 57       -     -57
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/8 up/down: 23/-164)          Total: -141 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 15:39:19 +02:00
Denys Vlasenko
0ee0b658b3 hush: small speedup in handle_changed_special_names()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 11:32:26 +02:00
Denys Vlasenko
9bf6780c28 shell: add TODO comment about BASE#nnn literals
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-16 09:56:45 +02:00
Denys Vlasenko
9e0adb9b09 hush: fix quoted "${notexist-}" expansion to not disappear
function                                             old     new   delta
expand_one_var                                      2296    2311     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-15 13:39:19 +02:00
Denys Vlasenko
63d765e666 shells: add tests for backslashes in export VAR=VAL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 19:15:20 +02:00
Denys Vlasenko
d8bd7012a3 hush: fix "export PS1=xyz" and "local PS1=xyz" messing up prompt
function                                             old     new   delta
helper_export_local                                  215     253     +38
leave_var_nest_level                                 107     127     +20
run_pipe                                            1840    1857     +17
handle_changed_special_names                         101     105      +4
shell_builtin_read                                  1399    1398      -1
done_word                                            767     766      -1
parse_stream                                        2249    2245      -4
set_local_var                                        437     430      -7
is_well_formed_var_name                               66       -     -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/4 up/down: 79/-79)              Total: 0 bytes
   text	   data	    bss	    dec	    hex	filename
 952376	    485	   7296	 960157	  ea69d	busybox_old
 952400	    485	   7296	 960181	  ea6b5	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-14 18:56:04 +02:00
Denys Vlasenko
93f0b39a07 ash,hush: ulimit: add -i RLIMIT_SIGPENDING, -q RLIMIT_MSGQUEUE
function                                             old     new   delta
limits_tbl                                           104     120     +16
ulimit_opt_string                                     44      50      +6
limit_chars                                           14      16      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 24/0)               Total: 24 bytes
   text	   data	    bss	    dec	    hex	filename
 981996	    485	   7296	 989777	  f1a51	busybox_old
 982065	    485	   7296	 989846	  f1a96	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-28 11:25:11 +02:00
Denys Vlasenko
57e1b0ad5e ash,hush: bash compat for ulimit: reorder to match
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-28 11:20:09 +02:00
Denys Vlasenko
a92a9601f8 ash,hush: bash compat for ulimit: -w => -x, -p => -u
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-27 21:24:33 +02:00
Denys Vlasenko
a4d76ea137 ash,hush: fix ulimit to be more bash-compat, closes 11791
function                                             old     new   delta
shell_builtin_ulimit                                 486     651    +165
limit_chars                                            -      14     +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 179/0)             Total: 179 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-27 21:01:35 +02:00
Denys Vlasenko
1c356948f1 httpd: use full size of iobuf[] when piping CGI data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19 14:19:41 +02:00
Ron Yorston
d1a2fa2a4e ash: catch error in arithmetic expansion in PS1
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>
2019-04-19 13:21:34 +02:00
Ron Yorston
48645b8350 ash: prevent error in backquotes in PS1 from exiting shell
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>
2019-04-19 13:21:34 +02:00
Ron Yorston
1d37186fe2 ash: add bash-compatible EPOCH variables
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>
2019-04-16 18:29:52 +02:00
Ron Yorston
d96c69d876 ash: an unset dynamic variable should not be dynamic
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>
2019-04-16 18:29:52 +02:00
Ron Yorston
a81700bc08 hush: add bash-compatible EPOCH variables
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>
2019-04-16 18:29:52 +02:00
Ron Yorston
e48559eae3 ash: distinguish 'wait -n' from other bashisms
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>
2019-04-02 13:43:40 +02:00
Denys Vlasenko
e6f51ac697 hush: fix "wait -n" to wait for a _job_, not a _process_
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>
2019-03-27 18:35:19 +01:00
Denys Vlasenko
966f087ab4 ash: add "wait -n" bashism
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>
2019-03-27 15:52:17 +01:00
Denys Vlasenko
4d1c5149a0 hush: add "wait -n" bashism
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-26 18:34:06 +01:00
Ron Yorston
f55161ad27 ash: eval: avoid leaking memory associated with redirections. Closes 7748
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>
2019-02-25 18:57:59 +01:00