summaryrefslogtreecommitdiff
path: root/builtins.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2015-12-05 17:34:49 +0100
committerToby Goodwin <toby@paccrat.org>2018-04-26 06:52:32 +0100
commit68fc1605e7d3a317477abf1afc6410581724b72d (patch)
treecb4d83cb9f88b90838a7640f41ad15d7b2d36e56 /builtins.c
parent8ecd9704f9564950d8ea80c0fcff04b8861b37e4 (diff)
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.
Diffstat (limited to 'builtins.c')
-rw-r--r--builtins.c5
1 files changed, 5 insertions, 0 deletions
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);
+}
+