version 1.16, 2010/10/16 08:31:55 |
version 1.17, 2011/01/04 00:42:47 |
|
|
|
|
const struct cmd_entry cmd_pipe_pane_entry = { |
const struct cmd_entry cmd_pipe_pane_entry = { |
"pipe-pane", "pipep", |
"pipe-pane", "pipep", |
|
"ot:", 0, 1, |
CMD_TARGET_PANE_USAGE "[-o] [command]", |
CMD_TARGET_PANE_USAGE "[-o] [command]", |
CMD_ARG01, "o", |
0, |
cmd_target_init, |
NULL, |
cmd_target_parse, |
NULL, |
cmd_pipe_pane_exec, |
cmd_pipe_pane_exec |
cmd_target_free, |
|
cmd_target_print |
|
}; |
}; |
|
|
int |
int |
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct cmd_target_data *data = self->data; |
struct args *args = self->args; |
struct client *c; |
struct client *c; |
struct window_pane *wp; |
struct window_pane *wp; |
char *command; |
char *command; |
|
|
if ((c = cmd_find_client(ctx, NULL)) == NULL) |
if ((c = cmd_find_client(ctx, NULL)) == NULL) |
return (-1); |
return (-1); |
|
|
if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL) |
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) |
return (-1); |
return (-1); |
|
|
/* Destroy the old pipe. */ |
/* Destroy the old pipe. */ |
|
|
} |
} |
|
|
/* If no pipe command, that is enough. */ |
/* If no pipe command, that is enough. */ |
if (data->arg == NULL || *data->arg == '\0') |
if (args->argc == 0 || *args->argv[0] == '\0') |
return (0); |
return (0); |
|
|
/* |
/* |
|
|
* |
* |
* bind ^p pipep -o 'cat >>~/output' |
* bind ^p pipep -o 'cat >>~/output' |
*/ |
*/ |
if (cmd_check_flag(data->chflags, 'o') && old_fd != -1) |
if (args_has(self->args, 'o') && old_fd != -1) |
return (0); |
return (0); |
|
|
/* Open the new pipe. */ |
/* Open the new pipe. */ |
|
|
|
|
closefrom(STDERR_FILENO + 1); |
closefrom(STDERR_FILENO + 1); |
|
|
command = status_replace(c, NULL, data->arg, time(NULL), 0); |
command = status_replace(c, NULL, args->argv[0], time(NULL), 0); |
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL); |
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL); |
_exit(1); |
_exit(1); |
default: |
default: |