[PATCH] lineedit: skip non-executables when tab-completing commands

Ron Yorston rmy at frippery.org
Fri May 29 16:22:03 UTC 2015


Of course, on *nix systems there are probably very few non-executables
in directories on PATH.

Signed-off-by: Ron Yorston <rmy at pobox.com>
---
 libbb/lineedit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 2ddb2b6..1fd0dbc 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -817,6 +817,9 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
 			if (stat(found, &st) && lstat(found, &st))
 				goto cont; /* hmm, remove in progress? */
 
+			if (type == FIND_EXE_ONLY && !file_is_executable(found))
+				goto cont;
+
 			/* Save only name */
 			len = strlen(name_found);
 			found = xrealloc(found, len + 2); /* +2: for slash and NUL */
-- 
2.1.0



More information about the busybox mailing list