Commit Graph

624 Commits

Author SHA1 Message Date
Denys Vlasenko
0e13b4019c hush: use smaller EXP_FLAG_foo constants
function                                             old     new   delta
expand_string_to_string                              126     124      -2
parse_stream                                        2376    2370      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-8)               Total: -8 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-21 12:35:39 +02:00
Denys Vlasenko
52e460b744 hush: move shell_ver from globals to main's stack.
function                                             old     new   delta
hush_main                                            995    1011     +16
pseudo_exec_argv                                     253     251      -2
execvp_or_die                                         50      48      -2
maybe_set_to_sigexit                                  50      47      -3
hush_exit                                             78      75      -3
builtin_wait                                         274     271      -3
check_and_run_traps                                  205     200      -5
init_sigmasks                                        214     190     -24
builtin_trap                                         465     441     -24
reset_traps_to_defaults                              238     211     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 16/-93)            Total: -77 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 16:12:00 +02:00
Denys Vlasenko
bed7c81ea2 shell/math: deconvolute and explain ?: handling. Give better error message
function                                             old     new   delta
arith_apply                                         1271    1283     +12

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 11:50:46 +02:00
Denys Vlasenko
063847d6bd shell/math: return string error indicator, not integer
function                                             old     new   delta
expand_and_evaluate_arith                             87     106     +19
expand_one_var                                      1563    1570      +7
arith                                                 12      18      +6
evaluate_string                                      678     680      +2
arith_apply                                         1269    1271      +2
builtin_umask                                        133     132      -1
ash_arith                                            118      75     -43
expand_vars_to_list                                 1094    1038     -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/3 up/down: 36/-100)           Total: -64 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-15 13:33:02 +02:00
Denys Vlasenko
06d44d7dfb shell/math.c: rename arith_eval_hooks to arith_state, put error code into it
function                                             old     new   delta
expand_and_evaluate_arith                             79      89     +10
arith                                                675     674      -1
arith_lookup_val                                     151     142      -9
ash_arith                                            135     122     -13
arith_apply                                         1304    1269     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 10/-58)            Total: -48 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 12:49:03 +02:00
Denys Vlasenko
b771c654ca shell: shrink arith code; and prepare for returning text error codes
function                                             old     new   delta
arith                                                701     680     -21

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-13 00:34:26 +02:00
Denys Vlasenko
99862cbfad hush: optional support for history saving
function                                             old     new   delta
hush_main                                            945     995     +50

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 17:34:13 +02:00
Denys Vlasenko
de8c3f667a hush: move the EXIT trap comment. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 16:13:44 +02:00
Denys Vlasenko
a110c90de2 hush: fix EXIT trap display inside exit trap handler
function                                             old     new   delta
hush_exit                                             84      78      -6

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:38:04 +02:00
Denys Vlasenko
acd5bc8f64 hush: fix handling of \" in quoted/unquoted cmd
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-12 15:05:39 +02:00
Denys Vlasenko
5277a9db70 hush: remove forgotten commented-out block. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 15:34:53 +02:00
Denys Vlasenko
4f870496e7 hush: do fewer strdups in % and hash expansions
function                                             old     new   delta
builtin_umask                                        133     132      -1
expand_one_var                                      1552    1543      -9

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 11:06:01 +02:00
Denys Vlasenko
d98e5c65c3 hush: better function and parameter names
Also, trim code which isn't needed for non-bash compat.
No logic changes.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:44:23 +02:00
Denys Vlasenko
ebee410fe2 hush: fix var_bash5.tests failure
function                                             old     new   delta
expand_one_var                                      1513    1552     +39
expand_pseudo_dquoted                                118     135     +17
expand_string_to_string                              110     126     +16
setup_heredoc                                        298     308     +10
expand_and_evaluate_arith                             69      79     +10
parse_stream_dquoted                                 233     241      +8
setup_redirects                                      220     225      +5
run_list                                             956     961      +5
expand_assignments                                    76      81      +5
run_pipe                                            1587    1590      +3
parse_stream                                        2371    2374      +3
builtin_umask                                        132     133      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 12/0 up/down: 122/0)            Total: 122 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:17:53 +02:00
Denys Vlasenko
14e289b324 hush: fix var_bash3.tests failure
function                                             old     new   delta
expand_one_var                                      1513    1538     +25
parse_stream_dquoted                                 233     241      +8
expand_pseudo_dquoted                                118     126      +8
setup_heredoc                                        298     303      +5
expand_and_evaluate_arith                             69      74      +5
parse_stream                                        2371    2374      +3
builtin_umask                                        132     133      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/0 up/down: 55/0)               Total: 55 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:15:18 +02:00
Denys Vlasenko
a769e0225d hush: remove useless ESC_GLOB_CHARS clears/resotres
function                                             old     new   delta
o_addQstr                                             43     165    +122
expand_on_ifs                                        210     189     -21
expand_vars_to_list                                 1122    1094     -28
o_addqblock                                          139       -    -139
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 122/-188)          Total: -66 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-10 10:12:34 +02:00
Denys Vlasenko
bfc02a76c5 hush: fix a bug where expand_one_var wasn't restoring 1st char of the encoded $var
function                                             old     new   delta
expand_one_var                                      1515    1513      -2
expand_vars_to_list                                 1133    1122     -11

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:38:46 +02:00
Denys Vlasenko
101a4e3e21 hush: make parse_dollar flag quited status regardless of glob escaping status
function                                             old     new   delta
parse_stream_dquoted                                 228     233      +5
parse_stream                                        2369    2371      +2
parse_dollar                                         730     717     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 7/-13)              Total: -6 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 14:04:57 +02:00
Denys Vlasenko
5b6210cf49 hush: simplification in parse_stream, parse_stream_dquoted
function                                             old     new   delta
parse_stream                                        2354    2369     +15
parse_stream_dquoted                                 250     228     -22

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 13:32:21 +02:00
Denys Vlasenko
850b15bfaf hush: simplify parse_stream_dquoted
function                                             old     new   delta
parse_stream_dquoted                                 303     250     -53

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:58:19 +02:00
Denys Vlasenko
77a7b5519c hush: straighten out the logic in parse_stream
function                                             old     new   delta
parse_stream                                        2399    2354     -45

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-09 12:40:03 +02:00
Denys Vlasenko
95d48f2598 hush: eliminate redundant parameter of expand_vars_to_list()
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:58:55 +02:00
Denys Vlasenko
5b686cb8e6 hush: replace flag bytes in struct o_string with bit flags
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:44:34 +02:00
Denys Vlasenko
9b78255dca hush: remove unused enum typedef
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:33:26 +02:00
Denys Vlasenko
1fd3d94a6c hush: fix set -- q w e; (IFS='' echo "$*"; IFS=''; echo "$*"); echo "$*"
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-08 13:31:53 +02:00
Denys Vlasenko
8b2f13d84d shell: unify endofname() in hush and ash
function                                             old     new   delta
builtin_umask                                        132     133      +1
changepath                                           195     194      -1
expand_and_evaluate_arith                             77      69      -8
ash_arith                                            143     135      -8
expand_one_var                                      1551    1515     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 1/-53)             Total: -52 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 12:19:33 +02:00
Denys Vlasenko
27c56f1267 hush: a few relatively trivial simplifications
function                                             old     new   delta
helper_export_local                                  130     135      +5
set_vars_and_save_old                                 89      85      -4
expand_variables                                     147     141      -6
get_ptr_to_local_var                                  77      70      -7
get_local_var_value                                  171     164      -7
delete_finished_bg_job                                31      16     -15
hush_exit                                            101      84     -17
free_pipe_list                                        31      12     -19
check_and_run_traps                                  232     205     -27
free_pipe                                            205     130     -75
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 5/-177)           Total: -172 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:56:34 +02:00
Denys Vlasenko
da463fb007 hush: style cleanups. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-07 09:53:50 +02:00
Denys Vlasenko
605067b426 hush: revert a recent buggy change which resulted in two HUSH_VERSIONs
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 12:10:51 +02:00
Denys Vlasenko
83b900fb82 fix typo in comment
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:47:55 +02:00
Denys Vlasenko
c3adfacd22 hush: fix another corner case with backslashes in heredocs
function                                             old     new   delta
parse_stream                                        2395    2432     +37

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:46:03 +02:00
Denys Vlasenko
77b32ccbf2 hush: fix backslash and terminator handling in <<[-]["]heredoc["]
function                                             old     new   delta
parse_stream                                        2339    2395     +56
expand_pseudo_dquoted                                104     118     +14
parse_stream_dquoted                                 296     300      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 74/0)               Total: 74 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 11:27:32 +02:00
Denys Vlasenko
c49d2d9793 hush: fix globbing+backslashes in unquoted $var expansion
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:26:37 +02:00
Denys Vlasenko
d383b49aef hush: remove disabled CMD_SINGLEWORD_NOGLOB_COND, rename o_glob->perform_glob
+ other small tweaks to comments and such

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:22:13 +02:00
Denys Vlasenko
96f064d416 shell: remove lash and bbsh
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-06 10:18:21 +02:00
Denys Vlasenko
b36abf2dfc hush: big reordering: move parser functions to the beginning. no code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:50:59 +02:00
Denys Vlasenko
38292b68c9 hush: rename o_quoted to has_quoted_part; small code shrink
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:49:40 +02:00
Denys Vlasenko
f2dc20c2d5 hush: move variable expansion into a separate function. No logic changes
function                                             old     new   delta
expand_one_var                                         -    1551   +1551
expand_vars_to_list                                 2833    1175   -1658
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1551/-1658)       Total: -107 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:48:11 +02:00
Denys Vlasenko
36f774a0cd hush: add support for ${var/pattern/repl}, conditional on bash compat
function                                             old     new   delta
expand_vars_to_list                                 2386    2833    +447
expand_string_to_string                               69     110     +41
parse_dollar                                         681     721     +40
hush_main                                            963     945     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 528/-18)           Total: 510 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-05 14:47:58 +02:00
Denys Vlasenko
701e127f7d hush: optimize #[#] and %[%] for speed. size -2 bytes.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 21:21:07 +02:00
Denys Vlasenko
e298ce69ba hush: fix handling of backslashes in variable assignment
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-04 19:52:44 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
7783248eaa *: s/xatoi_u/xatoi_positive/g - I got bored of mistyping xatoi_u as xatou_i
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-12 14:14:45 +02:00
Denys Vlasenko
f3ea792bad *: mass cosmetic removal of extra empty lines. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-26 01:06:14 +02:00
Alexander Shishkin
ccb9771861 ash: fix $! value when traps are set
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-25 13:07:39 +02:00
Denys Vlasenko
6adf2aad38 hush: move msh/lash config into hush.c, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 19:26:38 +02:00
Denys Vlasenko
771f1995a9 ash: move config stuff into ash.c, no code chages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 14:31:34 +02:00
Denys Vlasenko
29082231d0 hush: fix multimple dependent variable expansion cases
function                                             old     new   delta
get_local_var_value                                  100     171     +71
expand_assignments                                    46      76     +30
reset_traps_to_defaults                              229     238      +9
maybe_set_to_sigexit                                  47      50      +3
init_sigmasks                                        211     214      +3
builtin_trap                                         462     465      +3
expand_vars_to_list                                 2412    2408      -4
run_pipe                                            1568    1533     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 119/-39)            Total: 80 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 13:52:32 +02:00
Denys Vlasenko
202a2d1219 hush: make set -x support optional
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:36:14 +02:00
Denys Vlasenko
3f5fae0772 hush: add support for set -x
function                                             old     new   delta
run_pipe                                            1442    1568    +126
dump_cmd_in_x_mode                                     -     126    +126
builtin_trap                                         441     462     +21
pseudo_exec_argv                                     171     187     +16
reset_traps_to_defaults                              214     229     +15
check_and_run_traps                                  227     232      +5
hush_exit                                             98     101      +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 6/0 up/down: 312/0)             Total: 312 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-16 12:35:35 +02:00