diff options
| author | Ron Yorston <rmy@pobox.com> | 2018-11-01 12:51:10 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-11-01 12:51:10 +0100 |
| commit | c9e161277eae5d2af39704e220ca5652e69bc428 (patch) | |
| tree | bb5f1bf277d0c6a65860a4d694f2ebc86a3c36b5 | |
| parent | b0df5af0fad7969a10d3910465bfd0ff518b1358 (diff) | |
| download | busybox-w32-c9e161277eae5d2af39704e220ca5652e69bc428.tar.gz busybox-w32-c9e161277eae5d2af39704e220ca5652e69bc428.tar.bz2 busybox-w32-c9e161277eae5d2af39704e220ca5652e69bc428.zip | |
lineedit: autocompletion for embedded scripts
function old new delta
complete_cmd_dir_file 811 826 +15
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | libbb/lineedit.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index aef1911d9..618e7c221 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
| @@ -812,14 +812,20 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type) | |||
| 812 | } | 812 | } |
| 813 | pf_len = strlen(pfind); | 813 | pf_len = strlen(pfind); |
| 814 | 814 | ||
| 815 | # if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 | 815 | # if ENABLE_FEATURE_SH_STANDALONE && (NUM_APPLETS != 1 || NUM_SCRIPTS > 0) |
| 816 | if (type == FIND_EXE_ONLY && !dirbuf) { | 816 | if (type == FIND_EXE_ONLY && !dirbuf) { |
| 817 | const char *p = applet_names; | 817 | const char *p; |
| 818 | 818 | # if NUM_APPLETS != 1 && NUM_SCRIPTS > 0 | |
| 819 | for (i = 0, p = applet_names; i < 2; i++, p = script_names) | ||
| 820 | # elif NUM_APPLETS != 1 /* and NUM_SCRIPTS == 0 */ | ||
| 821 | p = applet_names; | ||
| 822 | # else /* NUM_APPLETS == 1 && NUM_SCRIPTS > 0 */ | ||
| 823 | p = script_names; | ||
| 824 | # endif | ||
| 819 | while (*p) { | 825 | while (*p) { |
| 820 | if (strncmp(pfind, p, pf_len) == 0) | 826 | if (strncmp(pfind, p, pf_len) == 0) |
| 821 | add_match(xstrdup(p)); | 827 | add_match(xstrdup(p)); |
| 822 | while (*p++ != '\0') | 828 | while (*p++) |
| 823 | continue; | 829 | continue; |
| 824 | } | 830 | } |
| 825 | } | 831 | } |
