mirror of
https://github.com/tmux/tmux.git
synced 2025-04-19 10:48:47 +00:00
Only send end guard if begin was sent, from George Nachman.
This commit is contained in:
parent
87fe1c0b0e
commit
0ef24f9912
36
cmd-queue.c
36
cmd-queue.c
@ -151,6 +151,23 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print a guard line. */
|
||||||
|
int
|
||||||
|
cmdq_guard(struct cmd_q *cmdq, const char *guard)
|
||||||
|
{
|
||||||
|
struct client *c = cmdq->client;
|
||||||
|
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
return 0;
|
||||||
|
if (!(c->flags & CLIENT_CONTROL))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u\n", guard,
|
||||||
|
(long) cmdq->time, cmdq->number);
|
||||||
|
server_push_stdout(c);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add command list to queue and begin processing if needed. */
|
/* Add command list to queue and begin processing if needed. */
|
||||||
void
|
void
|
||||||
cmdq_run(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
cmdq_run(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
||||||
@ -179,16 +196,11 @@ cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist)
|
|||||||
int
|
int
|
||||||
cmdq_continue(struct cmd_q *cmdq)
|
cmdq_continue(struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct client *c = cmdq->client;
|
|
||||||
struct cmd_q_item *next;
|
struct cmd_q_item *next;
|
||||||
enum cmd_retval retval;
|
enum cmd_retval retval;
|
||||||
int guards, empty;
|
int empty, guard;
|
||||||
char s[1024];
|
char s[1024];
|
||||||
|
|
||||||
guards = 0;
|
|
||||||
if (c != NULL && c->session != NULL)
|
|
||||||
guards = c->flags & CLIENT_CONTROL;
|
|
||||||
|
|
||||||
notify_disable();
|
notify_disable();
|
||||||
|
|
||||||
empty = TAILQ_EMPTY(&cmdq->queue);
|
empty = TAILQ_EMPTY(&cmdq->queue);
|
||||||
@ -209,14 +221,16 @@ cmdq_continue(struct cmd_q *cmdq)
|
|||||||
log_debug("cmdq %p: %s (client %d)", cmdq, s,
|
log_debug("cmdq %p: %s (client %d)", cmdq, s,
|
||||||
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
|
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
|
||||||
|
|
||||||
if (guards)
|
cmdq->time = time(NULL);
|
||||||
cmdq_print(cmdq, "%%begin");
|
cmdq->number++;
|
||||||
|
|
||||||
|
guard = cmdq_guard(cmdq, "begin");
|
||||||
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
|
||||||
if (guards) {
|
if (guard) {
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
cmdq_print(cmdq, "%%error");
|
cmdq_guard(cmdq, "error");
|
||||||
else
|
else
|
||||||
cmdq_print(cmdq, "%%end");
|
cmdq_guard(cmdq, "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == CMD_RETURN_ERROR)
|
if (retval == CMD_RETURN_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user