"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>
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>
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>
Embedded scripts require a shell to be present in the BusyBox
binary. Allow either ash or hush to be used for this purpose.
If both are enabled ash takes precedence.
The size of the binary is unchanged in the default configuration:
both ash and hush are present but support for embedded scripts
isn't compiled into hush.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The HUSH_TICK configuration option enables command substitution,
not process substitution.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Was printing initial "+" prefix for the assignment, that printing
"+ cmd"
then printing the expanded " v=VAL" string.
Delay printing of "+" prefix for the assignment to after expansion.
function old new delta
run_pipe 1883 1902 +19
builtin_eval 127 133 +6
expand_vars_to_list 1103 1106 +3
dump_cmd_in_x_mode 144 142 -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 28/-2) Total: 26 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The n > 0 check to prevent access to the last byte of non-existing argv[-1]
wasn't enough. Switched to making sure there are initialized (zero) bytes there.
A predictable testcase is rather hard to construct, unfortunately,
contents of memory depends on allocator behavior and whatnot.
function old new delta
o_save_ptr_helper 119 137 +18
expand_on_ifs 345 339 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-6) Total: 12 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This necessitates switch from libc FILE api to a simple
homegrown replacement.
The change which fixes the bug here is the deleting of
restore_redirected_FILEs();
line. It was prematurely moving (restoring) script fd#3.
The fix is: we don't even _want_ to restore scrit fds,
we are perfectly fine with them being moved.
The only reason we tried to restore them is that FILE api
did not allow moving of FILE->fd.
function old new delta
refill_HFILE_and_getc - 93 +93
hfopen - 90 +90
hfclose - 66 +66
pseudo_exec_argv 591 597 +6
hush_main 1089 1095 +6
builtin_source 209 214 +5
save_fd_on_redirect 197 200 +3
setup_redirects 320 321 +1
fgetc_interactive 235 236 +1
i_peek_and_eat_bkslash_nl 99 97 -2
expand_vars_to_list 1103 1100 -3
restore_redirects 99 52 -47
fclose_and_forget 57 - -57
remember_FILE 63 - -63
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 6/3 up/down: 271/-172) Total: 99 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
o_free() made o_string NULL-initialized,
o_free_unsafe() did not bother reinitializing (expected caller to not need it).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This wasn't an ash bug in dollar_altvalue9, it was hush bug (and bash!)
function old new delta
expand_one_var 2236 2254 +18
expand_vars_to_list 1097 1103 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 24/0) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
ash might be a bit buggy, need to investigate dollar_altvalue9 test
function old new delta
expand_one_var 1639 2236 +597
expand_variables 112 128 +16
expand_vars_to_list 1117 1097 -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 613/-20) Total: 593 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This is necessary since expand_one_var() for ${var:+ARG} must create more than one
output word, and thus can't simply return a char*.
function old new delta
expand_one_var 1610 1643 +33
expand_vars_to_list 1139 1125 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 33/-14) Total: 19 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>