From d11ead7a06a76a83739ffe8de4d12cf4f659b4c8 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 8 Jul 2016 09:59:44 +0100 Subject: lineedit: tweak tab completion of commands in standalone shell mode When tab-completing commands in standalone shell mode: don't search the list of applet names if the command includes a path separator; since "busybox" doesn't appear in the list of applet names check for it separately. --- libbb/lineedit.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 6c91f1794..2566abd38 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -679,6 +679,14 @@ static void add_match(char *matched) num_matches++; } +#if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 +static void add_partial_match(const char *part, const char *full, int plen) +{ + if (strncmp(part, full, plen) == 0) + add_match(xstrdup(full)); +} +#endif + # if ENABLE_FEATURE_USERNAME_COMPLETION /* Replace "~user/..." with "/homedir/...". * The parameter is malloced, free it or return it @@ -826,15 +834,15 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) pf_len = strlen(pfind); #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 - if (type == FIND_EXE_ONLY) { + if (type == FIND_EXE_ONLY && dirbuf == NULL) { const char *p = applet_names; while (*p) { - if (strncmp(pfind, p, pf_len) == 0) - add_match(xstrdup(p)); + add_partial_match(pfind, p, pf_len); while (*p++ != '\0') continue; } + add_partial_match(pfind, "busybox", pf_len); } #endif -- cgit v1.2.3-55-g6feb