mirror of
https://github.com/tmux/tmux.git
synced 2026-06-03 16:46:18 +00:00
Merge branch 'obsd-master'
This commit is contained in:
@@ -44,9 +44,9 @@ const struct cmd_entry cmd_run_shell_entry = {
|
||||
.name = "run-shell",
|
||||
.alias = "run",
|
||||
|
||||
.args = { "bd:Ct:Es:c:", 0, 1, cmd_run_shell_args_parse },
|
||||
.args = { "bd:Ct:Es:c:", 0, -1, cmd_run_shell_args_parse },
|
||||
.usage = "[-bCE] [-c start-directory] [-d delay] " CMD_TARGET_PANE_USAGE
|
||||
" [shell-command]",
|
||||
" [shell-command [argument ...]]",
|
||||
|
||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
||||
|
||||
@@ -115,9 +115,11 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct session *s = target->s;
|
||||
struct window_pane *wp = target->wp;
|
||||
const char *delay, *cmd;
|
||||
struct format_tree *ft;
|
||||
double d;
|
||||
struct timeval tv;
|
||||
char *end;
|
||||
char *end, key[16];
|
||||
u_int i;
|
||||
int wait = !args_has(args, 'b');
|
||||
|
||||
if ((delay = args_get(args, 'd')) != NULL) {
|
||||
@@ -132,8 +134,15 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cdata = xcalloc(1, sizeof *cdata);
|
||||
if (!args_has(args, 'C')) {
|
||||
cmd = args_string(args, 0);
|
||||
if (cmd != NULL)
|
||||
cdata->cmd = format_single_from_target(item, cmd);
|
||||
if (cmd != NULL) {
|
||||
ft = format_create_from_target(item);
|
||||
for (i = 1; i < args_count(args); i++) {
|
||||
xsnprintf(key, sizeof key, "%u", i);
|
||||
format_add(ft, key, "%s", args_string(args, i));
|
||||
}
|
||||
cdata->cmd = format_expand(ft, cmd);
|
||||
format_free(ft);
|
||||
}
|
||||
} else {
|
||||
cdata->state = args_make_commands_prepare(self, item, 0, NULL,
|
||||
wait, 1);
|
||||
|
||||
9
format.c
9
format.c
@@ -5578,7 +5578,7 @@ format_expand1(struct format_expand_state *es, const char *fmt)
|
||||
const char *ptr, *s, *style_end = NULL;
|
||||
size_t off, len, n, outlen;
|
||||
int ch, brackets;
|
||||
char expanded[8192];
|
||||
char expanded[8192], number[2] = { 0 };
|
||||
|
||||
if (fmt == NULL || *fmt == '\0' || !format_check_time(es))
|
||||
return (xstrdup(""));
|
||||
@@ -5708,6 +5708,13 @@ format_expand1(struct format_expand_state *es, const char *fmt)
|
||||
continue;
|
||||
default:
|
||||
s = NULL;
|
||||
if (ch >= '1' && ch <= '9') {
|
||||
number[0] = ch;
|
||||
if (format_replace(es, number, 1, &buf, &len,
|
||||
&off) != 0)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (fmt > style_end) { /* skip inside #[] */
|
||||
if (ch >= 'A' && ch <= 'Z')
|
||||
s = format_upper[ch - 'A'];
|
||||
|
||||
16
tmux.1
16
tmux.1
@@ -7846,7 +7846,7 @@ option.
|
||||
.Op Fl c Ar start\-directory
|
||||
.Op Fl d Ar delay
|
||||
.Op Fl t Ar target\-pane
|
||||
.Op Ar shell\-command
|
||||
.Op Ar shell\-command Op Ar argument ...
|
||||
.Xc
|
||||
.D1 Pq alias: Ic run
|
||||
Execute
|
||||
@@ -7863,6 +7863,20 @@ Before being executed,
|
||||
is expanded using the rules specified in the
|
||||
.Sx FORMATS
|
||||
section.
|
||||
If
|
||||
.Ar argument
|
||||
values are given, they are available as
|
||||
.Ql #1 ,
|
||||
.Ql #2
|
||||
or
|
||||
.Ql #{1} ,
|
||||
.Ql #{2}
|
||||
and so on.
|
||||
For example:
|
||||
.Bd -literal -offset indent
|
||||
run-shell 'myscript.sh #1 #2' foo bar
|
||||
.Ed
|
||||
.Pp
|
||||
With
|
||||
.Fl b ,
|
||||
the command is run in the background.
|
||||
|
||||
Reference in New Issue
Block a user