sh: also auto-complete functions

Differential Revision:	https://reviews.freebsd.org/D40619
This commit is contained in:
Piotr Pawel Stefaniak 2023-04-30 18:31:52 +02:00
parent bec7b9a219
commit 8e5c53af83

View file

@ -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) {