From 74c755f2aba6402f9ec51fc6b4b61560884af46d Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 May 2015 23:12:38 +0000 Subject: Expand formats again inside #(), and free the temporaries. --- format.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'format.c') diff --git a/format.c b/format.c index 4fe1e924..a1165de6 100644 --- a/format.c +++ b/format.c @@ -490,7 +490,7 @@ format_expand_time(struct format_tree *ft, const char *fmt, time_t t) char * format_expand(struct format_tree *ft, const char *fmt) { - char *buf, *tmp; + char *buf, *tmp, *cmd; const char *ptr, *s; size_t off, len, n, slen; int ch, brackets; @@ -530,10 +530,14 @@ format_expand(struct format_tree *ft, const char *fmt) tmp = xmalloc(n + 1); memcpy(tmp, fmt, n); tmp[n] = '\0'; + cmd = format_expand(ft, tmp); - s = format_job_get(ft, tmp); + s = format_job_get(ft, cmd); slen = strlen(s); + free(cmd); + free(tmp); + while (len - off < slen + 1) { buf = xreallocarray(buf, 2, len); len *= 2; -- cgit From 2a8c2648f0375994715b2fea9de144b15c9588a2 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 May 2015 23:26:52 +0000 Subject: Don't use special strings if #() commands fail, just remove the format (as if the command produced nothing). Makes constructions that can fail like '#(test whatever && echo foo)' work as they did before. --- format.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'format.c') diff --git a/format.c b/format.c index a1165de6..72d6bfc9 100644 --- a/format.c +++ b/format.c @@ -175,17 +175,6 @@ format_job_callback(struct job *job) fj->job = NULL; free(fj->out); - if (WIFEXITED(job->status) && WEXITSTATUS(job->status) != 0) { - xasprintf(&fj->out, "<'%s' exited with %d>", fj->cmd, - WEXITSTATUS(job->status)); - return; - } - if (WIFSIGNALED(job->status)) { - xasprintf(&fj->out, "<'%s' got signal %d>", fj->cmd, - WTERMSIG(job->status)); - return; - } - buf = NULL; if ((line = evbuffer_readline(job->event->input)) == NULL) { len = EVBUFFER_LENGTH(job->event->input); -- cgit