summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2022-06-20 07:59:38 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2022-06-20 07:59:38 +0000
commit1b5bfba3d0886bbf25c21fd6e17b1a37881b1534 (patch)
tree329e10f156f861946886cf57b13c3028cc63e1e5 /usr.bin/tmux
parentcf51bafd72f939da660e381e6f3acd3dd24e86ec (diff)
Do not display configuration file errors in a pane when in control mode,
instead report them with a %config-error notification. GitHub issue 3193.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cfg.c26
-rw-r--r--usr.bin/tmux/cmd-new-session.c4
-rw-r--r--usr.bin/tmux/tmux.16
3 files changed, 28 insertions, 8 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c
index 34bae6b79a4..286c0017538 100644
--- a/usr.bin/tmux/cfg.c
+++ b/usr.bin/tmux/cfg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cfg.c,v 1.85 2022/05/30 13:00:18 nicm Exp $ */
+/* $OpenBSD: cfg.c,v 1.86 2022/06/20 07:59:37 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -52,8 +52,7 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
return (CMD_RETURN_NORMAL);
cfg_finished = 1;
- if (!RB_EMPTY(&sessions))
- cfg_show_causes(RB_MIN(sessions, &sessions));
+ cfg_show_causes(NULL);
if (cfg_item != NULL)
cmdq_continue(cfg_item);
@@ -239,11 +238,29 @@ cfg_print_causes(struct cmdq_item *item)
void
cfg_show_causes(struct session *s)
{
+ struct client *c = TAILQ_FIRST(&clients);
struct window_pane *wp;
struct window_mode_entry *wme;
u_int i;
- if (s == NULL || cfg_ncauses == 0)
+ if (cfg_ncauses == 0)
+ return;
+
+ if (c != NULL && (c->flags & CLIENT_CONTROL)) {
+ for (i = 0; i < cfg_ncauses; i++) {
+ control_write(c, "%%config-error %s", cfg_causes[i]);
+ free(cfg_causes[i]);
+ }
+ goto out;
+ }
+
+ if (s == NULL) {
+ if (c != NULL && c->session != NULL)
+ s = c->session;
+ else
+ s = RB_MIN(sessions, &sessions);
+ }
+ if (s == NULL || s->attached == 0) /* wait for an attached session */
return;
wp = s->curw->window->active;
@@ -255,6 +272,7 @@ cfg_show_causes(struct session *s)
free(cfg_causes[i]);
}
+out:
free(cfg_causes);
cfg_causes = NULL;
cfg_ncauses = 0;
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c
index eb71df910ad..a3c1f82bbd2 100644
--- a/usr.bin/tmux/cmd-new-session.c
+++ b/usr.bin/tmux/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-new-session.c,v 1.144 2021/08/27 17:25:55 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.145 2022/06/20 07:59:37 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -335,7 +335,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
/*
* If there are still configuration file errors to display, put the new
- * session's current window into more mode and display them now.
+ * session's current window into view mode and display them now.
*/
if (cfg_finished)
cfg_show_causes(s);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 25eb227d176..c437541d74c 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.891 2022/06/14 07:29:00 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.892 2022/06/20 07:59:37 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 14 2022 $
+.Dd $Mdocdate: June 20 2022 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -6529,6 +6529,8 @@ The client is now attached to the session with ID
.Ar session-id ,
which is named
.Ar name .
+.It Ic %config-error Ar error
+An error has happened in a configuration file.
.It Ic %continue Ar pane-id
The pane has been continued after being paused (if the
.Ar pause-after