summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston2018-11-01 12:51:10 +0100
committerDenys Vlasenko2018-11-01 12:51:10 +0100
commitc9e161277eae5d2af39704e220ca5652e69bc428 (patch)
treebb5f1bf277d0c6a65860a4d694f2ebc86a3c36b5
parentb0df5af0fad7969a10d3910465bfd0ff518b1358 (diff)
downloadbusybox-c9e161277eae5d2af39704e220ca5652e69bc428.zip
busybox-c9e161277eae5d2af39704e220ca5652e69bc428.tar.gz
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.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index aef1911..618e7c2 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)
}
pf_len = strlen(pfind);
-# if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1
+# if ENABLE_FEATURE_SH_STANDALONE && (NUM_APPLETS != 1 || NUM_SCRIPTS > 0)
if (type == FIND_EXE_ONLY && !dirbuf) {
- const char *p = applet_names;
-
+ const char *p;
+# if NUM_APPLETS != 1 && NUM_SCRIPTS > 0
+ for (i = 0, p = applet_names; i < 2; i++, p = script_names)
+# elif NUM_APPLETS != 1 /* and NUM_SCRIPTS == 0 */
+ p = applet_names;
+# else /* NUM_APPLETS == 1 && NUM_SCRIPTS > 0 */
+ p = script_names;
+# endif
while (*p) {
if (strncmp(pfind, p, pf_len) == 0)
add_match(xstrdup(p));
- while (*p++ != '\0')
+ while (*p++)
continue;
}
}