aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-10-12 14:46:48 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-10-12 14:46:48 +0000
commit37f17a7e5b42156a325f2f3207610455cb004ad0 (patch)
tree5ba7b4a68cbc48e8d8a904fc0e4b35582615fca1
parent514d6fa1ec60563318c67806334c3b8d97c95b02 (diff)
downloadrtmux-37f17a7e5b42156a325f2f3207610455cb004ad0.tar.gz
rtmux-37f17a7e5b42156a325f2f3207610455cb004ad0.tar.bz2
rtmux-37f17a7e5b42156a325f2f3207610455cb004ad0.zip
Warn and bork on nested sessions ($TMUX exists).
-rw-r--r--CHANGES3
-rw-r--r--TODO1
-rw-r--r--cmd-attach-session.c4
-rw-r--r--cmd-new-session.c4
-rw-r--r--server-msg.c8
-rw-r--r--tmux.c5
-rw-r--r--tmux.h3
7 files changed, 18 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index 988da18a..a7f84cfa 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
12 October 2007
+* (nicm) Add a warning if $TMUX exists on new/attach.
* (nicm) send-prefix command. Bound to C-b by default.
* (nicm) set status, status-fg, status-bg commands. fg and bg are as a number
from 0 to 8 or a string ("red", "blue", etc). status may be 1/0, on/off,
@@ -126,5 +127,5 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.40 2007-10-12 13:51:44 nicm Exp $
+$Id: CHANGES,v 1.41 2007-10-12 14:46:48 nicm Exp $
diff --git a/TODO b/TODO
index 631c2958..791bf519 100644
--- a/TODO
+++ b/TODO
@@ -57,5 +57,4 @@
kill window (C-b backsp)
kill session (no not bind by default)
set shell
-- handle tmux in tmux (check $TMUX and abort)
- check for some reqd terminfo caps on startup
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 18c388f3..0795a7ac 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-attach-session.c,v 1.5 2007-10-04 22:04:01 nicm Exp $ */
+/* $Id: cmd-attach-session.c,v 1.6 2007-10-12 14:46:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -38,7 +38,7 @@ struct cmd_attach_session_data {
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach", "[-d]",
- 0,
+ CMD_CANTNEST,
cmd_attach_session_parse,
cmd_attach_session_exec,
cmd_attach_session_send,
diff --git a/cmd-new-session.c b/cmd-new-session.c
index dfc894f3..564aa909 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-session.c,v 1.10 2007-10-04 22:04:01 nicm Exp $ */
+/* $Id: cmd-new-session.c,v 1.11 2007-10-12 14:46:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -40,7 +40,7 @@ struct cmd_new_session_data {
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new", "[-d] [-n session name] [command]",
- CMD_STARTSERVER|CMD_NOSESSION,
+ CMD_STARTSERVER|CMD_NOSESSION|CMD_CANTNEST,
cmd_new_session_parse,
cmd_new_session_exec,
cmd_new_session_send,
diff --git a/server-msg.c b/server-msg.c
index 41f4aa63..6fa574c8 100644
--- a/server-msg.c
+++ b/server-msg.c
@@ -1,4 +1,4 @@
-/* $Id: server-msg.c,v 1.25 2007-10-04 22:04:01 nicm Exp $ */
+/* $Id: server-msg.c,v 1.26 2007-10-12 14:46:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -123,6 +123,12 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
ctx.client = c;
ctx.flags = 0;
+ if (data.sid.pid != -1 && (cmd->entry->flags & CMD_CANTNEST)) {
+ server_msg_fn_command_error(&ctx, "sessions should be nested "
+ "with care. unset $TMUX and retry to force");
+ return (0);
+ }
+
if (cmd->entry->flags & CMD_NOSESSION)
ctx.session = NULL;
else {
diff --git a/tmux.c b/tmux.c
index af28548c..17296af5 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.30 2007-10-12 12:08:51 nicm Exp $ */
+/* $Id: tmux.c,v 1.31 2007-10-12 14:46:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -210,7 +210,8 @@ main(int argc, char **argv)
exit(1);
}
- if (!(cmd->entry->flags & CMD_NOSESSION))
+ if (!(cmd->entry->flags & CMD_NOSESSION) ||
+ (cmd->entry->flags & CMD_CANTNEST))
client_fill_sessid(&data.sid, name);
if (client_init(path, &cctx, cmd->entry->flags & CMD_STARTSERVER) != 0)
exit(1);
diff --git a/tmux.h b/tmux.h
index 8dfc8824..4461bbb5 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.57 2007-10-12 13:51:44 nicm Exp $ */
+/* $Id: tmux.h,v 1.58 2007-10-12 14:46:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -470,6 +470,7 @@ struct cmd_entry {
#define CMD_STARTSERVER 0x1
#define CMD_NOSESSION 0x2
+#define CMD_CANTNEST 0x4
int flags;
int (*parse)(void **, int, char **, char **);