From 68fc1605e7d3a317477abf1afc6410581724b72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Sat, 5 Dec 2015 17:34:49 +0100 Subject: Completion of command names and variables New completion entry functions for readline specific code: - compl_var for variables - compl_fn for functions - compl_builtin for builtins - compl_extcmd for external commands in path - compl_command, which combines the last three The first three are simple wrappers for compl_name, which iterates over a typical rc table (an array of structs) yielding the name fields. The appropriate completion entry function is chosen based on the character/token that preceeds the word to complete: '$' for variable, beginning of line or one of [`@|&(){;] for command. Otherwise the shell falls back to readline's default completion, which it also does, if the chosen completion entry function finds no match. --- builtins.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'builtins.c') diff --git a/builtins.c b/builtins.c index 42411ef..5a45435 100644 --- a/builtins.c +++ b/builtins.c @@ -636,3 +636,8 @@ static void b_limit(char **av) { } } #endif + +extern char *compl_builtin(const char *text, int state) { + return compl_name(text, state, &builtins[0].name, arraysize(builtins), &builtins[1].name - &builtins[0].name); +} + -- cgit v1.2.3