mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-28 08:02:54 +00:00
sh: also auto-complete functions
Differential Revision: https://reviews.freebsd.org/D40619
This commit is contained in:
parent
bec7b9a219
commit
8e5c53af83
@ -51,6 +51,7 @@ static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
|
||||
* Editline and history functions (and glue).
|
||||
*/
|
||||
#include "alias.h"
|
||||
#include "exec.h"
|
||||
#include "shell.h"
|
||||
#include "parser.h"
|
||||
#include "var.h"
|
||||
@ -621,6 +622,7 @@ static char
|
||||
char **matches = NULL, **rmatches;
|
||||
size_t i = 0, size = 16, uniq;
|
||||
size_t curpos = end - start, lcstring = -1;
|
||||
struct cmdentry e;
|
||||
|
||||
in_command_completion = false;
|
||||
if (start > 0 || memchr("/.~", text[0], 3) != NULL)
|
||||
@ -680,6 +682,16 @@ static char
|
||||
goto out;
|
||||
matches = rmatches;
|
||||
}
|
||||
for (const void *a = NULL; (a = itercmd(a, &e)) != NULL;) {
|
||||
if (e.cmdtype != CMDFUNCTION)
|
||||
continue;
|
||||
if (strncmp(e.cmdname, text, curpos) != 0)
|
||||
continue;
|
||||
rmatches = add_match(matches, ++i, &size, strdup(e.cmdname));
|
||||
if (rmatches == NULL)
|
||||
goto out;
|
||||
matches = rmatches;
|
||||
}
|
||||
out:
|
||||
free(free_path);
|
||||
if (i == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user