aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-12-12 13:27:20 +0000
committerRon Yorston <rmy@pobox.com>2023-12-12 13:27:20 +0000
commit8299b2403606e503012f2b6f3f41cbd500c631d4 (patch)
tree99d499dedf46a8eb29247510a0177c4242380083
parente4ab8fe064745abd57e3238f1ae29067e6ea8a22 (diff)
downloadbusybox-w32-8299b2403606e503012f2b6f3f41cbd500c631d4.tar.gz
busybox-w32-8299b2403606e503012f2b6f3f41cbd500c631d4.tar.bz2
busybox-w32-8299b2403606e503012f2b6f3f41cbd500c631d4.zip
lineedit: fix to tab completion of applet override
When the ability to override an applet if an external binary was present was added, the commit message for bd7018350 said: This doesn't affect tab completion in the shell: whether a completion is an applet or an external command is irrelevant. This isn't quite true. Suppose 'applet' has been overridden in such circumstances: $ export BB_OVERRIDE_APPLETS=";applet" $ applet If the user now enters tab twice the output would be: applet applet.exe The applet is still treated as a potential match. Recent changes to the applet override code result in a simple fix: the shell PATH can be passed to is_applet_preferred() in the line editing code. Now only 'applet.exe' is treated as a match. Adds 16-32 bytes.
-rw-r--r--libbb/lineedit.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 58ac68c22..efc5f8805 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -974,9 +974,11 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
974 if (type == FIND_EXE_ONLY && !dirbuf) { 974 if (type == FIND_EXE_ONLY && !dirbuf) {
975# if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1 975# if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1
976 const char *p = applet_names; 976 const char *p = applet_names;
977 const char *shpath = state->flags & WITH_PATH_LOOKUP ?
978 state->path_lookup : NULL;
977 while (*p) { 979 while (*p) {
978 if (strncmp(basecmd, p, baselen) == 0 && 980 if (strncmp(basecmd, p, baselen) == 0 &&
979 is_applet_preferred(p, NULL)) 981 is_applet_preferred(p, shpath))
980 add_match(xstrdup(p), TRUE); 982 add_match(xstrdup(p), TRUE);
981 while (*p++ != '\0') 983 while (*p++ != '\0')
982 continue; 984 continue;