diff options
author | Ron Yorston <rmy@pobox.com> | 2023-04-10 10:20:15 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-04-10 11:45:46 +0100 |
commit | 66c9b8f39acbba587eda0cababa3de37e89b8dff (patch) | |
tree | 732e6265edfd8e3a627c29f2b10410c9fa789ca6 /libbb | |
parent | 3165054d234e0f37f1a230312f1fd2ab3677bbc0 (diff) | |
download | busybox-w32-66c9b8f39acbba587eda0cababa3de37e89b8dff.tar.gz busybox-w32-66c9b8f39acbba587eda0cababa3de37e89b8dff.tar.bz2 busybox-w32-66c9b8f39acbba587eda0cababa3de37e89b8dff.zip |
ash,hush: tab completion of functions and aliases
Rework the 'get_exe_name' functions in ash and hush so functions
and aliases are considered when tab-completing a command.
function old new delta
ash_command_name - 188 +188
hush_command_name - 118 +118
complete_cmd_dir_file 876 880 +4
ash_builtin_name 17 - -17
hush_builtin_name 38 - -38
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/0 up/down: 310/-55) Total: 255 bytes
(GitHub issue #301)
Signed-off-by: Ron Yorston <rmy@pobox.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 625884adf..5daceff16 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -875,9 +875,13 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
875 | # endif | 875 | # endif |
876 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH | 876 | # if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH |
877 | if (state->get_exe_name) { | 877 | if (state->get_exe_name) { |
878 | i = 0; | 878 | # if ENABLE_SHELL_ASH || (ENABLE_SHELL_HUSH && ENABLE_HUSH_FUNCTIONS) |
879 | exe_state e = { 0, 0, NULL }; | ||
880 | # else | ||
881 | exe_state e = { 0, 0 }; | ||
882 | # endif | ||
879 | for (;;) { | 883 | for (;;) { |
880 | const char *b = state->get_exe_name(i++); | 884 | const char *b = state->get_exe_name(&e); |
881 | if (!b) | 885 | if (!b) |
882 | break; | 886 | break; |
883 | if (strncmp(basecmd, b, baselen) == 0) | 887 | if (strncmp(basecmd, b, baselen) == 0) |