summaryrefslogtreecommitdiff
path: root/mu
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2015-09-16 08:39:51 +0300
committerSergey Poznyakoff <gray@gnu.org>2015-09-16 08:44:07 +0300
commitf160ca75991d5bf994afe3cb5bc549b113b14bbd (patch)
treeb7fe10cf93f531af65e3925f9605bd697d2f8b9b /mu
parentcd2126bee8534176c4e28dcf8f326f19d3132279 (diff)
downloadmailutils-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.c16
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);

Return to:

Send suggestions and report system problems to the System administrator.