aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-04-13 12:56:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-16 17:15:05 +0200
commitacae889dd97280ee59b7e04c18005bb8875cb0d2 (patch)
treedcde9a9d1c328443b03e4004101b471d39f7fd6f /shell/hush.c
parent90b607d79a1377d6a5dda44ee112698c58432203 (diff)
downloadbusybox-w32-acae889dd97280ee59b7e04c18005bb8875cb0d2.tar.gz
busybox-w32-acae889dd97280ee59b7e04c18005bb8875cb0d2.tar.bz2
busybox-w32-acae889dd97280ee59b7e04c18005bb8875cb0d2.zip
ash,hush: tab completion of functions and aliases
Since commit 9e2a5668f (ash,hush: allow builtins to be tab-completed, closes 7532) ash and hush have supported tab completion of builtins. Other shells, bash and ksh for example, also support tab completion of functions and aliases. Add such support to ash and hush. function old new delta ash_command_name - 92 +92 hush_command_name - 63 +63 ash_builtin_name 17 - -17 hush_builtin_name 38 - -38 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 0/0 up/down: 169/-55) Total: 100 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Avi Halachmi <avihpit@yahoo.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 202c0993a..f8951d084 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -8220,7 +8220,7 @@ 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 get_builtin_name(int i) 8223static const char * FAST_FUNC hush_command_name(int i)
8224{ 8224{
8225 if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) { 8225 if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) {
8226 return bltins1[i].b_cmd; 8226 return bltins1[i].b_cmd;
@@ -8229,6 +8229,16 @@ static const char * FAST_FUNC get_builtin_name(int i)
8229 if (i < ARRAY_SIZE(bltins2)) { 8229 if (i < ARRAY_SIZE(bltins2)) {
8230 return bltins2[i].b_cmd; 8230 return bltins2[i].b_cmd;
8231 } 8231 }
8232# if ENABLE_HUSH_FUNCTIONS
8233 {
8234 struct function *funcp;
8235 i -= ARRAY_SIZE(bltins2);
8236 for (funcp = G.top_func; funcp; funcp = funcp->next) {
8237 if (--i < 0)
8238 return funcp->name;
8239 }
8240 }
8241# endif
8232 return NULL; 8242 return NULL;
8233} 8243}
8234#endif 8244#endif
@@ -10716,7 +10726,7 @@ int hush_main(int argc, char **argv)
10716# if ENABLE_FEATURE_EDITING 10726# if ENABLE_FEATURE_EDITING
10717 G.line_input_state = new_line_input_t(FOR_SHELL); 10727 G.line_input_state = new_line_input_t(FOR_SHELL);
10718# if ENABLE_FEATURE_TAB_COMPLETION 10728# if ENABLE_FEATURE_TAB_COMPLETION
10719 G.line_input_state->get_exe_name = get_builtin_name; 10729 G.line_input_state->get_exe_name = hush_command_name;
10720# endif 10730# endif
10721# if EDITING_HAS_sh_get_var 10731# if EDITING_HAS_sh_get_var
10722 G.line_input_state->sh_get_var = get_local_var_value; 10732 G.line_input_state->sh_get_var = get_local_var_value;