diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-29 11:54:29 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-29 11:54:29 +0300 |
commit | 63fec21357c175772a8ca153266919c12b6f8bd5 (patch) | |
tree | 7f4110d849cdb68167c278dba916d4a24f862e67 /mu/shell.c | |
parent | 90ba2e7e0c53957254719e46a7bd22e14b92a96c (diff) | |
download | mailutils-63fec21357c175772a8ca153266919c12b6f8bd5.tar.gz mailutils-63fec21357c175772a8ca153266919c12b6f8bd5.tar.bz2 |
Use wordsplit to expand command prompt in mu.
* mu/mu.h (mutool_prompt_vartab): Remove.
(mutool_prompt_env): New extern.
* mu/pop.c (pop_prompt_vartab): Rewrite as pop_prompt_env.
All callers changed.
* mu/shell.c (mutool_prompt_vartab): Remove variable.
(mutool_prompt_env): New variable.
(expand_prompt): Remove function.
(input_line_interactive): Use mu_wordsplit to expand command prompt.
Diffstat (limited to 'mu/shell.c')
-rw-r--r-- | mu/shell.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/mu/shell.c b/mu/shell.c index 910a13a32..51ed25afe 100644 --- a/mu/shell.c +++ b/mu/shell.c @@ -31,21 +31,10 @@ #endif char *mutool_shell_prompt; -mu_vartab_t mutool_prompt_vartab; +char **mutool_prompt_env; int mutool_shell_interactive; mu_stream_t mustrin, mustrout; -static char * -expand_prompt () -{ - char *str; - - if (!mutool_prompt_vartab - || mu_vartab_expand (mutool_prompt_vartab, mutool_shell_prompt, &str)) - str = strdup (mutool_shell_prompt); - return str; -} - static int shell_exit (int, char **); static int shell_help (int, char **); @@ -516,9 +505,22 @@ execute_line (char *line) static char * input_line_interactive () { - char *p = expand_prompt (); - char *line = readline (p); - free (p); + char *line; + int wsflags = MU_WRDSF_NOSPLIT | MU_WRDSF_NOCMD; + struct mu_wordsplit ws; + + if (mutool_prompt_env) + { + ws.ws_env = (const char **)mutool_prompt_env; + wsflags |= MU_WRDSF_ENV | MU_WRDSF_ENV_KV; + } + if (mu_wordsplit (mutool_shell_prompt, &ws, wsflags)) + line = readline (mutool_shell_prompt); + else + { + line = readline (ws.ws_wordv[0]); + mu_wordsplit_free (&ws); + } return line; } |