diff options
author | Ron Yorston <rmy@pobox.com> | 2015-06-17 09:18:39 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-06-17 09:18:39 +0100 |
commit | 899efb44dbc38410a546ed740c1bff4881da0e96 (patch) | |
tree | 9af8271de3da0576fa7579f66987a4c11914c8dc /libbb | |
parent | 6a71ef3e25272126afc61a95067823941c57322c (diff) | |
download | busybox-w32-899efb44dbc38410a546ed740c1bff4881da0e96.tar.gz busybox-w32-899efb44dbc38410a546ed740c1bff4881da0e96.tar.bz2 busybox-w32-899efb44dbc38410a546ed740c1bff4881da0e96.zip |
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.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 15 |
1 files changed, 14 insertions, 1 deletions
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 @@ | |||
47 | * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw" | 47 | * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw" |
48 | * calculation of how many lines the prompt takes. | 48 | * calculation of how many lines the prompt takes. |
49 | */ | 49 | */ |
50 | #include "libbb.h" | 50 | #include "busybox.h" |
51 | #include "NUM_APPLETS.h" | ||
51 | #include "unicode.h" | 52 | #include "unicode.h" |
52 | #ifndef _POSIX_VDISABLE | 53 | #ifndef _POSIX_VDISABLE |
53 | # define _POSIX_VDISABLE '\0' | 54 | # define _POSIX_VDISABLE '\0' |
@@ -824,6 +825,18 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
824 | } | 825 | } |
825 | pf_len = strlen(pfind); | 826 | pf_len = strlen(pfind); |
826 | 827 | ||
828 | #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 | ||
829 | if (type == FIND_EXE_ONLY) { | ||
830 | const char *p = applet_names; | ||
831 | |||
832 | for (i=0; i < NUM_APPLETS; i++) { | ||
833 | if (strncmp(pfind, p, pf_len) == 0) | ||
834 | add_match(xstrdup(p)); | ||
835 | p += strlen(p) + 1; | ||
836 | } | ||
837 | } | ||
838 | #endif | ||
839 | |||
827 | for (i = 0; i < npaths; i++) { | 840 | for (i = 0; i < npaths; i++) { |
828 | DIR *dir; | 841 | DIR *dir; |
829 | struct dirent *next; | 842 | struct dirent *next; |