summaryrefslogtreecommitdiffstats
path: root/cmd-set-buffer.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-19 18:23:40 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-19 18:23:40 +0000
commit93230a64bc9369c726cc68d3f539b3bf66cff069 (patch)
tree0ad90cda9a0db39a058cbac8ceec67e6e7215354 /cmd-set-buffer.c
parent5f6a351df72f76f98ee1ed3494d025fe591fdb69 (diff)
Pass return code from _exec; allow command sequences to work from the command line.
Diffstat (limited to 'cmd-set-buffer.c')
-rw-r--r--cmd-set-buffer.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index 9f93afe4..dd8f4336 100644
--- a/cmd-set-buffer.c
+++ b/cmd-set-buffer.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-set-buffer.c,v 1.5 2009-01-14 22:16:57 nicm Exp $ */
+/* $Id: cmd-set-buffer.c,v 1.6 2009-01-19 18:23:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -26,7 +26,7 @@
* Add or set a session paste buffer.
*/
-void cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
+int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_set_buffer_entry = {
"set-buffer", "setb",
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_set_buffer_entry = {
cmd_buffer_print
};
-void
+int
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_buffer_data *data = self->data;
@@ -49,16 +49,15 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
u_int limit;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
- return;
+ return (-1);
limit = options_get_number(&s->options, "buffer-limit");
if (data->buffer == -1)
paste_add(&s->buffers, data->arg, limit);
- else {
- if (paste_replace(&s->buffers, data->buffer, data->arg) != 0)
- ctx->error(ctx, "no buffer %d", data->buffer);
+ else if (paste_replace(&s->buffers, data->buffer, data->arg) != 0) {
+ ctx->error(ctx, "no buffer %d", data->buffer);
+ return (-1);
}
- if (ctx->cmdclient != NULL)
- server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+ return (0);
}