diff options
author | Ron Yorston <rmy@pobox.com> | 2016-07-08 09:59:44 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-07-08 09:59:44 +0100 |
commit | d11ead7a06a76a83739ffe8de4d12cf4f659b4c8 (patch) | |
tree | bb611dc73a8d1453653c5071fab5a0dd4f0cc18b | |
parent | 60a45c4c924b301facd8171ec0b541c066887b59 (diff) | |
download | busybox-w32-d11ead7a06a76a83739ffe8de4d12cf4f659b4c8.tar.gz busybox-w32-d11ead7a06a76a83739ffe8de4d12cf4f659b4c8.tar.bz2 busybox-w32-d11ead7a06a76a83739ffe8de4d12cf4f659b4c8.zip |
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.
-rw-r--r-- | libbb/lineedit.c | 14 |
1 files 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) | |||
679 | num_matches++; | 679 | num_matches++; |
680 | } | 680 | } |
681 | 681 | ||
682 | #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 | ||
683 | static void add_partial_match(const char *part, const char *full, int plen) | ||
684 | { | ||
685 | if (strncmp(part, full, plen) == 0) | ||
686 | add_match(xstrdup(full)); | ||
687 | } | ||
688 | #endif | ||
689 | |||
682 | # if ENABLE_FEATURE_USERNAME_COMPLETION | 690 | # if ENABLE_FEATURE_USERNAME_COMPLETION |
683 | /* Replace "~user/..." with "/homedir/...". | 691 | /* Replace "~user/..." with "/homedir/...". |
684 | * The parameter is malloced, free it or return it | 692 | * 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) | |||
826 | pf_len = strlen(pfind); | 834 | pf_len = strlen(pfind); |
827 | 835 | ||
828 | #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 | 836 | #if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 |
829 | if (type == FIND_EXE_ONLY) { | 837 | if (type == FIND_EXE_ONLY && dirbuf == NULL) { |
830 | const char *p = applet_names; | 838 | const char *p = applet_names; |
831 | 839 | ||
832 | while (*p) { | 840 | while (*p) { |
833 | if (strncmp(pfind, p, pf_len) == 0) | 841 | add_partial_match(pfind, p, pf_len); |
834 | add_match(xstrdup(p)); | ||
835 | while (*p++ != '\0') | 842 | while (*p++ != '\0') |
836 | continue; | 843 | continue; |
837 | } | 844 | } |
845 | add_partial_match(pfind, "busybox", pf_len); | ||
838 | } | 846 | } |
839 | #endif | 847 | #endif |
840 | 848 | ||