summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-11-19 10:22:08 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-11-19 10:22:08 +0000
commit845be9c312d2c37fb306423861d72d102a1ee841 (patch)
treea78ff8f18e3d397e3cffef1f6af78169b45f3959 /usr.bin/tmux
parent8b12ee1bb78ac0a27cbe0aa1285ad6c24a55095e (diff)
Don't interpret #() for display-message, it usually doesn't make sense and may
leak commands.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-display-message.c4
-rw-r--r--usr.bin/tmux/server-client.c4
-rw-r--r--usr.bin/tmux/status.c32
-rw-r--r--usr.bin/tmux/tmux.113
-rw-r--r--usr.bin/tmux/tmux.h4
5 files changed, 36 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c
index fcfe1749743..9914f46f6b6 100644
--- a/usr.bin/tmux/cmd-display-message.c
+++ b/usr.bin/tmux/cmd-display-message.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-message.c,v 1.4 2009/11/13 19:53:29 nicm Exp $ */
+/* $OpenBSD: cmd-display-message.c,v 1.5 2009/11/19 10:22:06 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -55,7 +55,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
else
template = data->arg;
- msg = status_replace(c, template, time(NULL));
+ msg = status_replace(c, template, time(NULL), 0);
status_message_set(c, "%s", msg);
xfree(msg);
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 6115c9469d5..cafa2182405 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.21 2009/11/18 13:16:33 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.22 2009/11/19 10:22:06 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -489,7 +489,7 @@ server_client_set_title(struct client *c)
template = options_get_string(&s->options, "set-titles-string");
- title = status_replace(c, template, time(NULL));
+ title = status_replace(c, template, time(NULL), 1);
if (c->title == NULL || strcmp(title, c->title) != 0) {
if (c->title != NULL)
xfree(c->title);
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 088d1fc22f8..b622cf4b7ed 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.44 2009/11/18 13:16:33 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.45 2009/11/19 10:22:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -107,14 +107,14 @@ status_redraw(struct client *c)
/* Work out the left and right strings. */
left = status_replace(c, options_get_string(
- &s->options, "status-left"), c->status_timer.tv_sec);
+ &s->options, "status-left"), c->status_timer.tv_sec, 1);
llen = options_get_number(&s->options, "status-left-length");
llen2 = screen_write_cstrlen(utf8flag, "%s", left);
if (llen2 < llen)
llen = llen2;
right = status_replace(c, options_get_string(
- &s->options, "status-right"), c->status_timer.tv_sec);
+ &s->options, "status-right"), c->status_timer.tv_sec, 1);
rlen = options_get_number(&s->options, "status-right-length");
rlen2 = screen_write_cstrlen(utf8flag, "%s", right);
if (rlen2 < rlen)
@@ -319,7 +319,7 @@ out:
}
char *
-status_replace(struct client *c, const char *fmt, time_t t)
+status_replace(struct client *c, const char *fmt, time_t t, int run_jobs)
{
struct session *s = c->session;
struct winlink *wl = s->curw;
@@ -355,11 +355,25 @@ status_replace(struct client *c, const char *fmt, time_t t)
ptr = NULL;
switch (*iptr++) {
case '(':
- if (ptr == NULL) {
- ptr = status_job(c, &iptr);
- if (ptr == NULL)
- break;
- savedptr = ptr;
+ if (run_jobs) {
+ if (ptr == NULL) {
+ ptr = status_job(c, &iptr);
+ if (ptr == NULL)
+ break;
+ savedptr = ptr;
+ }
+ } else {
+ /* Don't run jobs. Copy to ). */
+ *optr++ = '#';
+
+ iptr--; /* include [ */
+ while (*iptr != ')' && *iptr != '\0') {
+ if (optr >=
+ out + (sizeof out) - 1)
+ break;
+ *optr++ = *iptr++;
+ }
+ break;
}
/* FALLTHROUGH */
case 'H':
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 4d4520c3172..3eed1f0134e 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.121 2009/11/18 17:02:17 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.122 2009/11/19 10:22:07 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -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: November 18 2009 $
+.Dd $Mdocdate: November 19 2009 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1992,10 +1992,11 @@ This command works only from inside
.Op Ar message
.Xc
.D1 (alias: Ic display )
-Display a message (see the
-.Ic status-left
-option below)
-in the status line.
+Display a message in the status line.
+The format of
+.Ar message is as for
+.Ic status-left ,
+with the exception that #() are not handled.
.It Ic select-prompt Op Fl t Ar target-client
Open a prompt inside
.Ar target-client
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 871c48bb077..dd35f0ca0b9 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.181 2009/11/18 17:02:17 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.182 2009/11/19 10:22:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1617,7 +1617,7 @@ void server_update_event(struct client *);
/* status.c */
int status_redraw(struct client *);
-char *status_replace(struct client *, const char *, time_t);
+char *status_replace(struct client *, const char *, time_t, int);
void printflike2 status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);