aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 330a0aa79..443bdeccf 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -8220,15 +8220,35 @@ static const struct built_in_command *find_builtin(const char *name)
8220} 8220}
8221 8221
8222#if ENABLE_HUSH_JOB && ENABLE_FEATURE_TAB_COMPLETION 8222#if ENABLE_HUSH_JOB && ENABLE_FEATURE_TAB_COMPLETION
8223static const char * FAST_FUNC hush_builtin_name(int i) 8223static const char * FAST_FUNC hush_command_name(exe_state *e)
8224{ 8224{
8225 if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { 8225 if (e->e_type == 0) {
8226 return bltins1[i].b_cmd; 8226 if (/*e->e_index >= 0 && */ e->e_index < ARRAY_SIZE(bltins1)) {
8227 return bltins1[e->e_index++].b_cmd;
8228 }
8229 e->e_type++;
8230 e->e_index = 0;
8231 /* e->e_ptr = NULL; */
8232 }
8233 if (e->e_type == 1) {
8234 if (e->e_index < ARRAY_SIZE(bltins2)) {
8235 return bltins2[e->e_index++].b_cmd;
8236 }
8237# if ENABLE_HUSH_FUNCTIONS
8238 e->e_type++;
8239 /* e->e_index = 0; */
8240 e->e_ptr = G.top_func;
8241# endif
8227 } 8242 }
8228 i -= ARRAY_SIZE(bltins1); 8243# if ENABLE_HUSH_FUNCTIONS
8229 if (i < ARRAY_SIZE(bltins2)) { 8244 if (e->e_type == 2) {
8230 return bltins2[i].b_cmd; 8245 struct function *funcp = (struct function *)e->e_ptr;
8246 while (funcp) {
8247 e->e_ptr = funcp->next;
8248 return funcp->name;
8249 }
8231 } 8250 }
8251# endif
8232 return NULL; 8252 return NULL;
8233} 8253}
8234#endif 8254#endif
@@ -10716,7 +10736,7 @@ int hush_main(int argc, char **argv)
10716# if ENABLE_FEATURE_EDITING 10736# if ENABLE_FEATURE_EDITING
10717 G.line_input_state = new_line_input_t(FOR_SHELL); 10737 G.line_input_state = new_line_input_t(FOR_SHELL);
10718# if ENABLE_FEATURE_TAB_COMPLETION 10738# if ENABLE_FEATURE_TAB_COMPLETION
10719 G.line_input_state->get_exe_name = hush_builtin_name; 10739 G.line_input_state->get_exe_name = hush_command_name;
10720# endif 10740# endif
10721# if EDITING_HAS_sh_get_var 10741# if EDITING_HAS_sh_get_var
10722 G.line_input_state->sh_get_var = get_local_var_value; 10742 G.line_input_state->sh_get_var = get_local_var_value;