From 899efb44dbc38410a546ed740c1bff4881da0e96 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 17 Jun 2015 09:18:39 +0100 Subject: lineedit: search applets as well as PATH for tab completion In standalone shell mode search the applet table as well as PATH when tab completing a command. Use a stupid linear search: we're also about to read all the directories on PATH so efficiency isn't a big concern. --- libbb/lineedit.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 7982f2997..8d265a625 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -47,7 +47,8 @@ * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw" * calculation of how many lines the prompt takes. */ -#include "libbb.h" +#include "busybox.h" +#include "NUM_APPLETS.h" #include "unicode.h" #ifndef _POSIX_VDISABLE # define _POSIX_VDISABLE '\0' @@ -824,6 +825,18 @@ 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) { + const char *p = applet_names; + + for (i=0; i < NUM_APPLETS; i++) { + if (strncmp(pfind, p, pf_len) == 0) + add_match(xstrdup(p)); + p += strlen(p) + 1; + } + } +#endif + for (i = 0; i < npaths; i++) { DIR *dir; struct dirent *next; -- cgit v1.2.3-55-g6feb