Commit Graph

370 Commits

Author SHA1 Message Date
Denis Vlasenko
b1d11bf45e hush: more efficient filtering of "safe" arithmetic
function                                             old     new   delta
expand_variables                                    2170    2147     -23
2009-04-06 12:24:58 +00:00
Denis Vlasenko
d0b4a8c285 hush: add <> and () as "safe" arith chars 2009-04-06 12:09:55 +00:00
Denis Vlasenko
bfbc971f9f hush: print cd error to stderr; use fopen_or_warn in builtin_source;
prepare builtin_unset for function support
libbb: do not clear errno in fopen_or_warn

function                                             old     new   delta
builtin_unset                                        242     271     +29
fopen_or_warn                                         42      31     -11
builtin_cd                                            90      74     -16
builtin_source                                        89      72     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 29/-44)            Total: -15 bytes
2009-04-06 12:04:42 +00:00
Denis Vlasenko
b0a6478eef hush: fix "export a=a b=b" (was not setting and exporting b)
function                                             old     new   delta
builtin_export                                       103     117     +14
2009-04-06 11:33:07 +00:00
Denis Vlasenko
c8d27334a0 hush: update TODO list; + my usual pointless tweaks :( 2009-04-06 10:47:21 +00:00
Denis Vlasenko
d3f973eab2 hush: mark SIGHUP TODOs better; don't disable SIGHUP for now,
small tweaks to comments
2009-04-06 10:21:42 +00:00
Denis Vlasenko
a0e65120b5 hush: cosmetics, no code changes 2009-04-05 23:39:14 +00:00
Denis Vlasenko
913a201bf0 hush: strip NULs from file input, they are PITA/impossible to handle correctly
function                                             old     new   delta
file_peek                                             89      93      +4
file_get                                             260     264      +4
2009-04-05 22:17:04 +00:00
Mike Frysinger
258275d85f drop HUSH_VER_STR since it has no relevance anymore -- just use BB_VER 2009-04-05 21:19:43 +00:00
Denis Vlasenko
c4a7af55e9 hush: fix trap clearing in subshells on MMU; simplify NOMMU a bit:
function                                             old     new   delta
parse_stream_dquoted                                 335     324     -11
handle_dollar                                        849     800     -49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-60)             Total: -60 bytes
2009-04-05 20:33:27 +00:00
Denis Vlasenko
f937528571 hush: audit and fix "interactive shell" setup code.
function                                             old     new   delta
block_signals                                          -     139    +139
maybe_set_to_sigexit                                   -      47     +47
run_list                                            2018    2030     +12
expand_variables                                    2155    2165     +10
maybe_set_sighandler                                  47       -     -47
hush_main                                            992     918     -74
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 208/-121)           Total: 87 bytes
2009-04-05 19:13:39 +00:00
Denis Vlasenko
46f9b6db80 hush: pass $! thru re-execution; try harder on re-exec; give error
msg if re-exec didn't work; other tweaks in main()

function                                             old     new   delta
hush_main                                           1144    1199     +55
re_execute_shell                                     237     286     +49
file_get                                             240     260     +20
clean_up_after_re_execute                             58      66      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 132/0)             Total: 132 bytes
2009-04-05 10:39:03 +00:00
Denis Vlasenko
232be3e79b hush: suppress bogus warning from 4.2.1 2009-04-05 09:16:00 +00:00
Denis Vlasenko
d85a5df159 hush: randomconfig fixes 2009-04-05 08:43:57 +00:00
Denis Vlasenko
cc4c693ec5 hush: plug the leak on NOMMU re-execute path
function                                             old     new   delta
clean_up_after_re_execute                              -      58     +58
re_execute_shell                                     226     244     +18
run_pipe                                            1271    1276      +5
generate_stream_from_string                          133     138      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 86/0)               Total: 86 bytes
2009-04-05 07:38:48 +00:00
Denis Vlasenko
30db43b5c5 hush: fix passing of $n on NOMMU 2009-04-05 02:10:39 +00:00
Denis Vlasenko
16a0c74f63 hush: fix hush-misc/break5.tests NOMMU failure
function                                             old     new   delta
hush_main                                           1118    1144     +26
re_execute_shell                                     188     204     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0)               Total: 42 bytes
2009-04-05 01:46:59 +00:00
Denis Vlasenko
0bb4a23506 hush: fix all testsuite failures on NOMMU except memory leak.
known TODOs: we do not pass traps and positional args yet.
2009-04-05 01:42:59 +00:00
Denis Vlasenko
609f2ab434 hush: enable NOMMU re-execution logic. Some testsuite entries
fail on NOMMU. Before it was much worse.
 No regressions on MMU, size:

function                                             old     new   delta
handle_dollar                                        626     632      +6
run_list                                            2018    2022      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 10/0)               Total: 10 bytes
2009-04-04 23:15:14 +00:00
Denis Vlasenko
9aa7d6fdc5 hush: preparatory patch for NOMMU-safe { list } handling.
function                                             old     new   delta
o_addblock                                             -      58     +58
o_addstr_with_NUL                                      -      27     +27
builtin_exit                                          47      49      +2
run_list                                            2020    2018      -2
o_addstrauto                                          27       -     -27
parse_stream                                        1508    1461     -47
o_addstr                                              58       -     -58
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/2 up/down: 87/-134)           Total: -47 bytes
2009-04-04 22:47:50 +00:00
Denis Vlasenko
34d4d89b2d hush: fix NOMMU hangs in pseudo_exec_argv. Add forgotted setting
of signal mask. Reuse same help string in all shells.

function                                             old     new   delta
builtin_exit                                          49      47      -2
pseudo_exec_argv                                     149     145      -4
builtin_help                                          74      63     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-17)             Total: -17 bytes
   text    data     bss     dec     hex filename
 825379     476    7616  833471   cb7bf busybox_old
 825341     476    7616  833433   cb799 busybox_unstripped
2009-04-04 20:24:37 +00:00
Denis Vlasenko
552433bc5a hush: fix "var=val >file" not creating file
function                                             old     new   delta
static.null_ptr                                        -       4      +4
run_list                                            2018    2020      +2
handle_dollar                                        667     626     -41
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 6/-41)             Total: -35 bytes
2009-04-04 19:29:21 +00:00
Denis Vlasenko
a24c8caeb2 hush: remove code which errors out on $- and $_, it's useless;
wrap some longish lines

function                                             old     new   delta
handle_dollar                                        667     626     -41
2009-04-04 15:24:40 +00:00
Denis Vlasenko
7c9861214b hush: remove CHAR_xxx constants 2009-04-04 12:15:42 +00:00
Denis Vlasenko
6da69cddc0 hush: get rid of charmap[]
function                                             old     new   delta
parse_stream                                        1447    1508     +61
get_local_var_value                                    -      31     +31
run_list                                            2018    2020      +2
pseudo_exec_argv                                     151     149      -2
maybe_set_sighandler                                  50      47      -3
hush_exit                                             93      90      -3
builtin_wait                                         275     272      -3
check_and_run_traps                                  169     164      -5
hush_main                                            985     977      -8
file_get                                             260     240     -20
builtin_trap                                         438     414     -24
set_in_charmap                                        30       -     -30
lookup_param                                          31       -     -31
parse_and_run_stream                                 153      54     -99
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/9 up/down: 94/-228)          Total: -134 bytes
2009-04-04 12:12:58 +00:00
Mike Frysinger
dfa9de7176 simplify maybe_die() slightly 2009-04-03 22:48:10 +00:00
Denis Vlasenko
db2a9b683a hush: finally make cmd safe on NOMMU
function                                             old     new   delta
generate_stream_from_string                            -     157    +157
expand_variables                                    2050    2003     -47
generate_stream_from_list                            139       -    -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 157/-186)          Total: -29 bytes
2009-04-03 22:31:18 +00:00
Denis Vlasenko
e0755e58ca hush: yet another randomconfig fix 2009-04-03 21:16:45 +00:00
Denis Vlasenko
60b392fd5b hush: randomconfig fixes 2009-04-03 19:14:32 +00:00
Denis Vlasenko
b6e6556b31 hush: improve parse_stream: does not require parsing context struct;
cleans up on syntax errors (we used to leak memory in this case);
 much simplified interface to the rest of hush.

function                                             old     new   delta
parse_stream                                        1204    1447    +243
done_word                                            658     669     +11
static_get                                            22      28      +6
builtin_source                                        84      89      +5
parse_and_run_file                                    27      30      +3
parse_and_run_string                                  31      27      -4
builtin_eval                                          55      50      -5
hush_main                                            991     985      -6
free_pipe_list                                        39      31      -8
free_pipe                                            210     189     -21
expand_variables                                    2242    2199     -43
parse_and_run_stream                                 289     153    -136
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/7 up/down: 268/-223)           Total: 45 bytes
2009-04-03 16:49:04 +00:00
Denis Vlasenko
240c255d8b hush: simplify parse_stream
function                                             old     new   delta
parse_and_run_stream                                 292     289      -3
parse_stream                                        1218    1204     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-17)             Total: -17 bytes
2009-04-03 03:45:05 +00:00
Denis Vlasenko
3718168b87 hush: fix bug with local environment vars in pipes; simplify parse_stream()
function                                             old     new   delta
parse_stream                                        1238    1218     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20)             Total: -20 bytes
2009-04-03 03:19:15 +00:00
Denis Vlasenko
f9f7429346 hush: explain parsing context structure
plug leak in setup_redirect on error path

function                                             old     new   delta
done_command                                          84      86      +2
done_word                                            657     658      +1
done_pipe                                            105     106      +1
initialize_context                                    39      38      -1
setup_redirect                                       219     212      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 4/-8)               Total: -4 bytes
2009-04-03 00:07:05 +00:00
Denis Vlasenko
027e3fddb5 hush: straighten parse_stream() API a bit
function                                             old     new   delta
parse_stream                                        1240    1238      -2
expand_variables                                    2272    2242     -30
parse_and_run_stream                                 338     292     -46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-78)             Total: -78 bytes
2009-04-02 22:50:40 +00:00
Denis Vlasenko
b7aaae9052 hush: rename ->o_quote to ->o_escape
hush_test/hush-arith/*: new tests for arithmetic evaluation
2009-04-02 20:17:49 +00:00
Mike Frysinger
7a79afa3ca Arithmetic Expansion is supported now in hush, so drop from TODO 2009-04-02 17:06:35 +00:00
Denis Vlasenko
f328e00b10 hush: do not inadvertently parse $((1 + "22")) as ok.
-20 bytes code size
2009-04-02 16:55:38 +00:00
Denis Vlasenko
2f1d394214 hush: make
a=55; echo $(($a + 1)) $((1 + $((2)) + `echo $a`))
 work as expected

function                                             old     new   delta
handle_dollar                                          -     667    +667
parse_stream_dquoted                                   -     316    +316
expand_variables                                    2124    2272    +148
is_assignment                                        134     215     +81
parse_stream                                        2038    1240    -798
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/1 up/down: 1212/-798)         Total: 414 bytes
2009-04-02 16:31:29 +00:00
Denis Vlasenko
b29eb6ed25 shells: do not need to have math state global
function                                             old     new   delta                           
ash_arith                                              -     143    +143                           
expand_variables                                    2102    2124     +22                           
popstring                                            134     140      +6                           
parse_command                                       1460    1463      +3                           
trapcmd                                              236     238      +2                           
changepath                                           197     196      -1                           
raise_interrupt                                       86      83      -3                           
hush_main                                           1012     991     -21                           
ash_main                                            1388    1364     -24                           
arith_set_local_var                                   73      34     -39                           
dash_arith                                           117       -    -117                           
------------------------------------------------------------------------------                     
(add/remove: 1/1 grow/shrink: 4/5 up/down: 176/-205)          Total: -29 bytes
2009-04-02 13:46:27 +00:00
Mike Frysinger
98c52645c0 split math code out of ash and into a standalone library so we can use it in any shell (like hush!) 2009-04-02 10:02:37 +00:00
Denis Vlasenko
7566bae197 hush: fix wait builtin
function                                             old     new   delta
builtin_wait                                         174     275    +101
sigwaitinfo                                            -      48     +48
__GI_sigwaitinfo                                       -      48     +48
check_and_run_traps                                  133     169     +36
checkjobs                                            349     380     +31
hush_main                                            971     991     +20
static.zero_timespec                                   -       8      +8
run_list                                            2010    2016      +6
file_get                                             254     260      +6
static.zero_ts                                         8       -      -8
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 6/0 up/down: 304/-8)            Total: 296 bytes
2009-03-31 17:24:49 +00:00
Denis Vlasenko
1b62ead313 hush: don't lie in comment 2009-03-31 13:13:17 +00:00
Denis Vlasenko
7b830e78f2 hush: fix comments, no code changes 2009-03-31 13:05:32 +00:00
Denis Vlasenko
422cd7c81c hush: make ^C work again, ^Z probably isn't working
function                                             old     new   delta
file_get                                             219     254     +35
check_and_run_traps                                  122     133     +11
run_list                                            2001    2010      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 55/0)               Total: 55 bytes
2009-03-31 12:41:52 +00:00
Denis Vlasenko
abedaac842 hush: do not reset sighaldlers after fork - instead, prevent them from doing any harm
if they will be called. saves many sigaction calls on every fork.

function                                             old     new   delta
hush_main                                            887     971     +84
sigexit                                               54      65     +11
run_list                                            2006    2001      -5
maybe_set_sighandler                                  76      50     -26
set_fatal_sighandler                                 186       -    -186
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 95/-217)          Total: -122 bytes
2009-03-31 12:03:40 +00:00
Denis Vlasenko
d5762932fb hush: rework signal and trap handling. Some smaller bits are TODO,
expect minor breakage

function                                             old     new   delta
set_fatal_sighandler                                  12     186    +174
check_and_run_traps                                    -     122    +122
maybe_set_sighandler                                   -      76     +76
hush_main                                            831     887     +56
sigtimedwait                                           -      50     +50
__GI_sigtimedwait                                      -      50     +50
hush_exit                                             49      93     +44
set_mode                                             749     777     +28
pseudo_exec_argv                                     131     151     +20
static.zero_ts                                         -       8      +8
expand_variables                                    1962    1970      +8
builtin_wait                                         172     174      +2
set_misc_sighandler                                   12       -     -12
set_jobctrl_sighandler                                12       -     -12
handler_ctrl_c                                        16       -     -16
builtin_set_mode                                      28       -     -28
handle_trap                                           97       -     -97
handler_ctrl_z                                       107       -    -107
builtin_trap                                         545     438    -107
run_list                                            2149    2006    -143
------------------------------------------------------------------------------
(add/remove: 5/6 grow/shrink: 7/2 up/down: 638/-522)          Total: 116 bytes
2009-03-31 11:22:57 +00:00
Mike Frysinger
d690f68554 implement unset semantics as required by POSIX 2009-03-30 06:50:54 +00:00
Mike Frysinger
0080ea7992 update trap poisx link 2009-03-30 03:50:07 +00:00
Mike Frysinger
87824e0e50 do not automatically display job information when the shell is not interactive 2009-03-30 00:19:30 +00:00
Mike Frysinger
9f8128f480 first pass at trap support in hush 2009-03-29 23:49:37 +00:00