From a55e569af513deb99258354822ee75cbdce83619 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 May 2015 23:02:27 +0000 Subject: [PATCH 1/3] Use RB_MIN to get the lowest index for the current window when creating grouped sessions, rather than using RB_ROOT. --- cmd-new-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-new-session.c b/cmd-new-session.c index 199e82c2..9c767489 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -254,7 +254,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) if (groupwith != NULL) { session_group_add(groupwith, s); session_group_synchronize_to(s); - session_select(s, RB_ROOT(&s->windows)->idx); + session_select(s, RB_MIN(winlinks, &s->windows)->idx); } /* From 74c755f2aba6402f9ec51fc6b4b61560884af46d Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 May 2015 23:12:38 +0000 Subject: [PATCH 2/3] Expand formats again inside #(), and free the temporaries. --- format.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; From 2a8c2648f0375994715b2fea9de144b15c9588a2 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 May 2015 23:26:52 +0000 Subject: [PATCH 3/3] 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(-) 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);