diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-23 17:29:52 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-23 17:29:52 +0000 |
commit | 087ae957eb631e47da2a7dd5ca83a4459f71d35c (patch) | |
tree | 493bbeec359ea52b06367a3ff626927fb3243667 /usr.bin | |
parent | 64dd9c8a82fcdea3d677666c748bfacd6b4f0121 (diff) |
When using source-file, run the commands in the context of the source-file
command rather than with no context. This makes things like attach work from a
file.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cfg.c | 17 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-source-file.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/server.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
4 files changed, 18 insertions, 13 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index 92515418fbc..4103de6178a 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.5 2009/08/23 16:45:00 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.6 2009/08/23 17:29:51 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -51,7 +51,7 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...) } int -load_cfg(const char *path, char **cause) +load_cfg(const char *path, struct cmd_ctx *ctxin, char **cause) { FILE *f; u_int n; @@ -87,15 +87,20 @@ load_cfg(const char *path, char **cause) continue; cfg_cause = NULL; - ctx.msgdata = NULL; - ctx.curclient = NULL; + if (ctxin == NULL) { + ctx.msgdata = NULL; + ctx.curclient = NULL; + ctx.cmdclient = NULL; + } else { + ctx.msgdata = ctxin->msgdata; + ctx.curclient = ctxin->curclient; + ctx.cmdclient = ctxin->cmdclient; + } ctx.error = cfg_error; ctx.print = cfg_print; ctx.info = cfg_print; - ctx.cmdclient = NULL; - cfg_cause = NULL; cmd_list_exec(cmdlist, &ctx); cmd_list_free(cmdlist); diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 6193a4fafc7..89a21202299 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.4 2009/08/23 17:29:51 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha <me@tiagocunha.org> @@ -90,7 +90,7 @@ cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx) struct cmd_source_file_data *data = self->data; char *cause; - if (load_cfg(data->path, &cause) != 0) { + if (load_cfg(data->path, ctx, &cause) != 0) { ctx->error(ctx, "%s", cause); xfree(cause); return (-1); diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index 0fb287fc2db..c665a745389 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.23 2009/08/18 21:37:04 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.24 2009/08/23 17:29:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -188,9 +188,9 @@ server_start(char *path) &cause, "%s: %s", strerror(errno), SYSTEM_CFG); goto error; } - } else if (load_cfg(SYSTEM_CFG, &cause) != 0) + } else if (load_cfg(SYSTEM_CFG, NULL, &cause) != 0) goto error; - if (cfg_file != NULL && load_cfg(cfg_file, &cause) != 0) + if (cfg_file != NULL && load_cfg(cfg_file, NULL, &cause) != 0) goto error; exit(server_main(srv_fd)); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 4532a2df7bd..d43a17764dd 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.88 2009/08/23 16:45:00 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.89 2009/08/23 17:29:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1109,7 +1109,7 @@ void sigreset(void); void sighandler(int); /* cfg.c */ -int load_cfg(const char *, char **x); +int load_cfg(const char *, struct cmd_ctx *, char **); /* mode-key.c */ extern const struct mode_key_table mode_key_tables[]; |