diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 0d40e1c9ec1a..842c166159bc 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -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) {