git: 8e5c53af831b - main - sh: also auto-complete functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 12 Sep 2023 16:42:57 UTC
The branch main has been updated by pstef:
URL: https://cgit.FreeBSD.org/src/commit/?id=8e5c53af831bd180af0c59f2d96c67ab9da59590
commit 8e5c53af831bd180af0c59f2d96c67ab9da59590
Author: Piotr Pawel Stefaniak <pstef@FreeBSD.org>
AuthorDate: 2023-04-30 16:31:52 +0000
Commit: Piotr Pawel Stefaniak <pstef@FreeBSD.org>
CommitDate: 2023-09-12 16:40:05 +0000
sh: also auto-complete functions
Differential Revision: https://reviews.freebsd.org/D40619
---
bin/sh/histedit.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
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) {