Commit Graph

57 Commits

Author SHA1 Message Date
Denys Vlasenko
a67a9627d0 hush: do not process options after non-option args
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 03:38:58 +02:00
Denys Vlasenko
cbfe6ad4c6 hush: fix \<newline> handling on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 19:47:44 +02:00
Denys Vlasenko
295fef80bc hush: add support for local builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 12:47:26 +02:00
Denys Vlasenko
4f26c97b9a make compound.tests executable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 17:00:13 +02:00
Denys Vlasenko
e9bda90e54 hush: fix problems with case in subshells and with "case esac"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 16:50:07 +02:00
Mike Frysinger
342a63d659 hush_test: add some pathological compound list tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:37 -04:00
Mike Frysinger
12bcc76e9b hush_test: test for subshell function syntax
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:08 -04:00
Mike Frysinger
7b424fe738 hush_test: add subshelled case tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:09:24 -04:00
Denys Vlasenko
318a8e5ed5 TODO: add some
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-13 02:18:43 +02:00
Denys Vlasenko
cb6ff25afe hush: fix bug where in "var=val func" var's value is not visible in func
function                                             old     new   delta
unset_local_var                                        -     168    +168
set_vars_all_and_save_old                              -      87     +87
get_ptr_to_local_var                                   -      77     +77
free_strings_and_unset                                 -      53     +53
builtin_export                                       266     274      +8
get_local_var_value                                   31      33      +2
putenv_all                                            27       -     -27
free_strings_and_unsetenv                             53       -     -53
get_local_var                                         68       -     -68
run_list                                            2475    2350    -125
builtin_unset                                        380     220    -160
------------------------------------------------------------------------------
(add/remove: 4/3 grow/shrink: 2/2 up/down: 395/-433)          Total: -38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 00:14:30 +02:00
Denys Vlasenko
1dd6cf8677 hush: fix multiple redirections of the same fd (bug 227)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 14:17:31 +02:00
Denis Vlasenko
572930027d hush: nommu fix for function passing 2009-04-26 20:06:14 +00:00
Denis Vlasenko
ad4bd0548a hush: export -n support
function                                             old     new   delta
builtin_export                                       206     256     +50
set_local_var                                        248     265     +17
expand_variables                                    2204    2203      -1
2009-04-20 22:04:21 +00:00
Denis Vlasenko
d40fa397e4 hush: add two testcases 2009-04-20 10:52:31 +00:00
Denis Vlasenko
8c64e033c0 hush: fix stdin of backgrounded pipe
function                                             old     new   delta
run_list                                            2450    2502     +52
2009-04-20 00:34:01 +00:00
Denis Vlasenko
bf25fbccb9 hush: fix handling of } which is not a closing one in { cmd; }
function                                             old     new   delta
parse_stream                                        2176    2302    +126
builtin_unset                                        381     387      +6
2009-04-19 13:57:51 +00:00
Denis Vlasenko
3d40d8e655 hush: return builtin by Bayram Kurumahmut (kbayram AT ubicom.com)
~+200 bytes
2009-04-17 23:44:18 +00:00
Denis Vlasenko
ce4acbbab6 hush: add function tests 2009-04-10 23:23:41 +00:00
Denis Vlasenko
0b677d8337 hush: fix some TODOs. TODO in export builting: +250 bytes.
simplify unexpected EOF handling.

function                                             old     new   delta
builtin_export                                       117     374    +257
o_reset_to_empty_unquoted                              -      21     +21
parse_stream                                        1926    1929      +3
syntax_error_unterm_ch                                31      32      +1
handle_dollar                                        644     641      -3
parse_stream_dquoted                                 307     298      -9
add_till_backquote                                   106      97      -9
add_till_closing_paren                               303     286     -17
o_reset                                               21       -     -21
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/4 up/down: 282/-59)           Total: 223 bytes
2009-04-10 13:49:10 +00:00
Denis Vlasenko
1fd1ea4395 hush: tighten up "for" variable name check.
Add TODOs.
 Disable redir4.right part where we differ from bash.
 It is not a bug per standards.
 Add a few tests, one is in hush-bugs section:
 and_or_and_backgrounding.right. It will likely bite users
 in real world usage.
2009-04-10 12:03:20 +00:00
Denis Vlasenko
c96865f445 hush: readability improvements.
fix some more obscure bugs.
 a new redir4.tests is known to fail.
2009-04-10 00:20:58 +00:00
Denis Vlasenko
efea9d2819 hush: fix EXIT trap recursion case; check redirection failures
function                                             old     new   delta                          
run_pipe                                            1299    1328     +29                          
hush_exit                                             90     102     +12                          
hush_main                                           1172    1179      +7                          
run_list                                            1226    1225      -1                          
------------------------------------------------------------------------------                    
(add/remove: 0/0 grow/shrink: 3/1 up/down: 48/-1)              Total: 47 bytes
2009-04-09 13:43:11 +00:00
Denis Vlasenko
5c090a96f9 hush: more rodust detection of unterminated strings etc;
fix a case where we forget to copy `cmd` text;
 optimize nommu heredoc helper by not passing environment to it;
 add several tests

function                                             old     new   delta
add_till_closing_paren                               256     308     +52
parse_stream                                        2337    2378     +41
add_till_backquote                                    82     111     +29
re_execute_shell                                     269     284     +15
handle_dollar                                        802     812     +10
parse_stream_dquoted                                 316     320      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 151/0)             Total: 151 bytes
2009-04-08 21:51:33 +00:00
Denis Vlasenko
3dfb035d8d hush: echo \2>file fix 2009-04-08 09:29:14 +00:00
Denis Vlasenko
02d6f1ad72 hush: fix heredoc expansion of $var and cmd
function                                             old     new   delta
expand_pseudo_dquoted                                  -     104    +104
setup_heredoc                                        215     275     +60
done_word                                            669     691     +22
parse_stream                                        1899    1902      +3
setup_redirects                                      196     191      -5
free_pipe                                            189     183      -6
expand_variables                                    2349    2229    -120
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 189/-131)           Total: 58 bytes
2009-04-07 19:56:55 +00:00
Mike Frysinger
b509c9c670 add a pathological test case for here doc related to eof marker and other ugly corner cases 2009-04-07 06:06:05 +00:00
Denis Vlasenko
6c9be7f451 hush: heredoc support, based on patch by Mike Frysinger (vapier AT gentoo.org)
some TODOs are to be attacked later

function                                             old     new   delta
parse_stream                                        1461    1866    +405
parse_redirect                                         -     265    +265
setup_heredoc                                          -     116    +116
setup_redirects                                      151     196     +45
builtin_exit                                          49      47      -2
redirect_opt_num                                      61      55      -6
setup_redirect                                       212       -    -212
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/2 up/down: 831/-220)          Total: 611 bytes
2009-04-07 02:29:51 +00:00
Denis Vlasenko
0e15138c03 hush: fix "if false; then...fi" exitcode;
trim "keyword"-less hush by 10 bytes
2009-04-06 18:40:31 +00:00
Denis Vlasenko
4ed67dd3d5 make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
Denis Vlasenko
cd418a2670 hush: fix a bunch of obscure while/until/continue bugs
function                                             old     new   delta
run_list                                            1159    1214     +55
done_pipe                                            106     123     +17
done_command                                          86      98     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 84/0)               Total: 84 bytes
2009-04-06 18:08:35 +00:00
Denis Vlasenko
8f8d013afc *.tests should be executable 2009-04-06 16:27:51 +00:00
Denis Vlasenko
715f712d15 move hush-parsing/and-or.tests to hush-misc/*
(which probably needs to be renamed to hush-execution...)
2009-04-06 16:17:51 +00:00
Mike Frysinger
3c7167b508 add tests for basic fd open/close/dupe 2009-04-06 12:36:10 +00:00
Mike Frysinger
9052600feb fix redir1 tests -- usleep isnt standard in $PATH 2009-04-06 12:34:27 +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
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
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
2b576b8e76 hush: fix mishandling of a'b'c=fff as assignments. They are not.
function                                             old     new   delta
parse_stream                                        1920    2004     +84
done_word                                            715     752     +37
parse_and_run_stream                                 328     333      +5
builtin_exec                                          25      29      +4
pseudo_exec_argv                                     138     139      +1
run_list                                            2006    1999      -7
is_assignment                                        215     134     -81
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/2 up/down: 131/-88)            Total: 43 bytes
2008-08-04 00:46:07 +00:00
Denis Vlasenko
f173607520 hush: fix "case ... in <newline> word)..." 2008-07-31 10:09:26 +00:00
Denis Vlasenko
4554b721ad hush: small fix for repeated continue and fix for wrong loop depth count
after Ctrl-C; with testcase for first one
2008-07-29 13:36:09 +00:00
Denis Vlasenko
fcf37c3183 hush: fix break'ing out of {} and () groups; with testcase
function                                             old     new   delta
builtin_break                                         93     129     +36
builtin_continue                                      21      47     +26
run_list                                            1973    1976      +3
2008-07-29 11:37:15 +00:00
Denis Vlasenko
dadfb4975b hush: add #defines to switch off break/continue if loops are not supported
*: remove a few inline keywords
no code changes
2008-07-29 10:16:05 +00:00
Denis Vlasenko
918a34b9e0 hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
Denis Vlasenko
6a2d40f239 hush: support "break N" and "continue N"
fix non-detection of builtins and applets in "v=break; ...; $v; ..." case
 add testsuite entries for the above

function                                             old     new   delta
builtin_break                                         12      93     +81
run_list                                            1948    1971     +23
builtin_continue                                      12      21      +9
pseudo_exec_argv                                     132     138      +6
builtin_exec                                          23      25      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 121/0)             Total: 121 bytes
2008-07-28 23:07:06 +00:00
Denis Vlasenko
be709c24d4 hush: finish and enable optional case...esac support. Code size cost:
function                                             old     new   delta
run_list                                            1891    2075    +184
parse_stream                                        1764    1847     +83
expand_strvec_to_string                                -      83     +83
done_word                                            647     715     +68
static.reserved_list                                 144     168     +24
static.reserved_match                                  -      12     +12
done_pipe                                             95     105     +10
builtin_exit                                          48      46      -2
builtin_eval                                         127      54     -73
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/2 up/down: 464/-75)           Total: 389 bytes
2008-07-28 00:01:16 +00:00
Denis Vlasenko
733e3fbc2f hush: support "for if in do done then; do echo $if; done" case
function                                             old     new   delta
done_pipe                                             83      95     +12
parse_stream                                        1758    1764      +6
done_word                                            674     647     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 18/-27)             Total: -9 bytes
2008-07-06 10:01:13 +00:00
Denis Vlasenko
ff182a3d68 hush: support "for v; do ... done" syntax (implied 'in "$@"') 2008-07-05 20:29:59 +00:00
Denis Vlasenko
16c2fea280 hush: fix $$ handling 2008-06-17 12:28:44 +00:00
Denis Vlasenko
6eaf8deddd hush: fix "for a in; do echo 'I should never run'; done" bug 2008-06-17 12:09:21 +00:00
Denis Vlasenko
f8d01d3f66 hush: fix a bug where we were requiring semicolon here: (cmd;)
also fix a bug where after error prompt is not shown.

function                                             old     new   delta
parse_stream                                        1612    1638     +26
parse_and_run_stream                                 361     375     +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0)               Total: 40 bytes
2008-06-14 17:13:20 +00:00