diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-09-16 08:39:51 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-09-16 08:44:07 +0300 |
commit | f160ca75991d5bf994afe3cb5bc549b113b14bbd (patch) | |
tree | b7fe10cf93f531af65e3925f9605bd697d2f8b9b /mu | |
parent | cd2126bee8534176c4e28dcf8f326f19d3132279 (diff) | |
download | mailutils-f160ca75991d5bf994afe3cb5bc549b113b14bbd.tar.gz mailutils-f160ca75991d5bf994afe3cb5bc549b113b14bbd.tar.bz2 |
Port wordsplit from grecs 20616b88
The updated version supports tilde and pathname expansion, command
substitution and standard shell-like replacement constructs in
variable substitution, such as ${X:-V} etc.
* include/mailutils/wordsplit.h: Update.
* libmailutils/string/wordsplit.c: Update.
* libmailutils/tests/wsp.c: Update.
* libmailutils/tests/wordsplit.at: Update unescape test.
* libmailutils/imapio/create.c (mu_imapio_create): Initialize ws_escape
array.
* libmailutils/mime/mimehdr.c (_mime_header_parse): Likewise.
* libmailutils/tests/modmesg.c: Use mu_wordsplit with MU_WRDSF_NOSPLIT
to run expansions on the string.
* mu/shell.c (shell_prompt): Likewise.
Diffstat (limited to 'mu')
-rw-r--r-- | mu/shell.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mu/shell.c b/mu/shell.c index 8788717fc..539db5657 100644 --- a/mu/shell.c +++ b/mu/shell.c @@ -252,12 +252,16 @@ shell_help (int argc, char **argv) static int shell_prompt (int argc, char **argv) { - size_t size; + mu_wordsplit_t ws; - free (mutool_shell_prompt); - size = strlen (argv[1]); - mutool_shell_prompt = mu_alloc (size + 1); - mu_wordsplit_c_unquote_copy (mutool_shell_prompt, argv[1], size); + if (mu_wordsplit (argv[1], &ws, MU_WRDSF_NOSPLIT | MU_WRDSF_DEFFLAGS)) + mu_error ("mu_wordsplit: %s", mu_wordsplit_strerror (&ws)); + else + { + free (mutool_shell_prompt); + mutool_shell_prompt = mu_strdup (ws.ws_wordv[0]); + } + mu_wordsplit_free (&ws); return 0; } @@ -521,7 +525,7 @@ execute_line (char *line) int status = 0; ws.ws_comment = "#"; - ws.ws_escape = "\\\""; + ws.ws_escape[0] = ws.ws_escape[1] = "\\\\\"\""; rc = mu_wordsplit (line, &ws, MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT|MU_WRDSF_ESCAPE| MU_WRDSF_INCREMENTAL|MU_WRDSF_APPEND); |