Diff of /cmd-queue.c [7ea560] .. [1c2718] Maximize Restore

  Switch to side-by-side view

--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -154,18 +154,15 @@
 
 /* Print a guard line. */
 int
-cmdq_guard(struct cmd_q *cmdq, const char *guard)
-{
-	struct client	*c = cmdq->client;
-	int		 flags;
+cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
+{
+	struct client	*c = cmdq->client;
 
 	if (c == NULL)
 		return 0;
 	if (!(c->flags & CLIENT_CONTROL))
 		return 0;
 
-	flags = !!(cmdq->cmd->flags & CMD_CONTROL);
-
 	evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
 	    (long) cmdq->time, cmdq->number, flags);
 	server_push_stdout(c);
@@ -202,7 +199,7 @@
 {
 	struct cmd_q_item	*next;
 	enum cmd_retval		 retval;
-	int			 empty, guard;
+	int			 empty, guard, flags;
 	char			 s[1024];
 
 	notify_disable();
@@ -228,13 +225,16 @@
 			cmdq->time = time(NULL);
 			cmdq->number++;
 
-			guard = cmdq_guard(cmdq, "begin");
+			flags = !!(cmdq->cmd->flags & CMD_CONTROL);
+			guard = cmdq_guard(cmdq, "begin", flags);
+
 			retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
+
 			if (guard) {
 				if (retval == CMD_RETURN_ERROR)
-				    cmdq_guard(cmdq, "error");
+					cmdq_guard(cmdq, "error", flags);
 				else
-				    cmdq_guard(cmdq, "end");
+					cmdq_guard(cmdq, "end", flags);
 			}
 
 			if (retval == CMD_RETURN_ERROR)