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>
This commit is contained in:
Ron Yorston
2020-01-21 16:01:58 +00:00
committed by Denys Vlasenko
parent 1ff7002b1d
commit 9e2a5668fd
4 changed files with 62 additions and 4 deletions

View File

@ -7889,6 +7889,20 @@ static const struct built_in_command *find_builtin(const char *name)
return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]);
}
#if EDITING_HAS_get_exe_name
static const char * FAST_FUNC get_builtin_name(int i)
{
if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) {
return bltins1[i].b_cmd;
}
i -= ARRAY_SIZE(bltins1);
if (i < ARRAY_SIZE(bltins2)) {
return bltins2[i].b_cmd;
}
return NULL;
}
#endif
static void remove_nested_vars(void)
{
struct variable *cur;
@ -10268,6 +10282,9 @@ int hush_main(int argc, char **argv)
# if ENABLE_FEATURE_EDITING
G.line_input_state = new_line_input_t(FOR_SHELL);
# if EDITING_HAS_get_exe_name
G.line_input_state->get_exe_name = get_builtin_name;
# endif
# endif
# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0
{