Hi
Did you already tell me what tmux version you are using? If so, I've
forgotten.
On Tue, Dec 14, 2010 at 04:47:25PM -0500, Mark T. Kennedy wrote:
> 1) remove your .tmux.conf file (to simplify things)
> 2) create a file with just the word "new" in it called cmds
> 3) start tmux with the command:
>
> tmux start-server \; source cmds
>
> 4) do 'tmux attach' (question: why does it detach in the first place?)
The way tmux works is that every command has an internal return value:
this is a 0 for success, -1 for error and 1 for client-now-attached
(yes, they should be an enum but right now they aren't - diffs welcome).
If 0 or -1 is returned, the "command client" is told to exit; it is only
told to stick around and transition into the ready state if 1 is
returned.
The reason the client exists is because source-file is not able to
return 1. It calls load_cfg which does not collect the return values
from the commands, only their error messages.
This diff fixes that, the only caveat being that now source-file will
never return failure even if some commands fail - personally I think
this is fine.
More to follow on your other issues.
Index: cfg.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cfg.c,v
retrieving revision 1.11
diff -u -p -r1.11 cfg.c
--- cfg.c 25 May 2010 19:47:30 -0000 1.11
+++ cfg.c 21 Dec 2010 21:55:48 -0000
@@ -80,6 +80,7 @@ load_cfg(const char *path, struct cmd_ct
size_t len;
struct cmd_list *cmdlist;
struct cmd_ctx ctx;
+ int retval;
if ((f = fopen(path, "rb")) == NULL) {
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
@@ -88,6 +89,7 @@ load_cfg(const char *path, struct cmd_ct
n = 0;
line = NULL;
+ retval = 0;
while ((buf = fgetln(f, &len))) {
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
@@ -125,19 +127,17 @@ load_cfg(const char *path, struct cmd_ct
ctx.info = cfg_print;
cfg_cause = NULL;
- cmd_list_exec(cmdlist, &ctx);
+ if (cmd_list_exec(cmdlist, &ctx) == 1)
+ retval = 1;
cmd_list_free(cmdlist);
if (cfg_cause != NULL) {
cfg_add_cause(causes, "%s: %d: %s", path, n, cfg_cause);
xfree(cfg_cause);
- continue;
}
}
if (line != NULL)
xfree(line);
fclose(f);
- if (ARRAY_LENGTH(causes) != 0)
- return (-1);
- return (0);
+ return (retval);
}
Index: cmd-source-file.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-source-file.c,v
retrieving revision 1.9
diff -u -p -r1.9 cmd-source-file.c
--- cmd-source-file.c 6 Feb 2010 23:22:27 -0000 1.9
+++ cmd-source-file.c 21 Dec 2010 21:55:48 -0000
@@ -91,19 +91,35 @@ cmd_source_file_exec(struct cmd *self, s
struct cmd_source_file_data *data = self->data;
struct causelist causes;
char *cause;
+ struct window_pane *wp;
+ int retval;
u_int i;
ARRAY_INIT(&causes);
- if (load_cfg(data->path, ctx, &causes) != 0) {
+
+ retval = load_cfg(data->path, ctx, &causes);
+ if (ARRAY_EMPTY(&causes))
+ return (retval);
+
+ if (retval == 1 && !ARRAY_EMPTY(&sessions) && ctx->cmdclient != NULL) {
+ wp = ARRAY_FIRST(&sessions)->curw->window->active;
+ window_pane_set_mode(wp, &window_copy_mode);
+ window_copy_init_for_output(wp);
+ for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
+ cause = ARRAY_ITEM(&causes, i);
+ window_copy_add(wp, "%s", cause);
+ xfree(cause);
+ }
+ } else {
for (i = 0; i < ARRAY_LENGTH(&causes); i++) {
cause = ARRAY_ITEM(&causes, i);
ctx->print(ctx, "%s", cause);
xfree(cause);
}
- ARRAY_FREE(&causes);
}
+ ARRAY_FREE(&causes);
- return (0);
+ return (retval);
}
void
------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months. Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users