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. --- rc.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'rc.h') diff --git a/rc.h b/rc.h index 7ae0693..33d1460 100644 --- a/rc.h +++ b/rc.h @@ -181,6 +181,7 @@ extern int lineno; extern builtin_t *isbuiltin(char *); extern void b_exec(char **), funcall(char **), b_dot(char **), b_builtin(char **); extern char *which(char *, bool); +extern char *compl_builtin(const char *, int); /* except.c */ extern bool nl_on_intr; @@ -259,6 +260,9 @@ extern void whatare_all_vars(bool, bool); extern void whatare_all_signals(void); extern void prettyprint_var(int, char *, List *); extern void prettyprint_fn(int, char *, Node *); +extern char *compl_name(const char *, int, char **, size_t, ssize_t); +extern char *compl_fn(const char *, int); +extern char *compl_var(const char *, int); /* heredoc.c */ extern int heredoc(int); -- cgit v1.2.3