GitHub issue 2924.
-/* $OpenBSD: cmd-display-menu.c,v 1.33 2021/08/27 17:25:55 nicm Exp $ */
+/* $OpenBSD: cmd-display-menu.c,v 1.34 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
.name = "display-popup",
.alias = "popup",
- .args = { "BCc:d:Eh:t:w:x:y:", 0, -1, NULL },
- .usage = "[-BCE] [-c target-client] [-d start-directory] [-h height] "
- CMD_TARGET_PANE_USAGE " [-w width] "
- "[-x position] [-y position] [shell-command]",
+ .args = { "BCc:d:e:Eh:t:w:x:y:", 0, -1, NULL },
+ .usage = "[-BCE] [-c target-client] [-d start-directory] "
+ "[-e environment] [-h height] " CMD_TARGET_PANE_USAGE " "
+ "[-w width] [-x position] [-y position] [shell-command]",
.target = { 't', CMD_FIND_PANE, 0 },
char *cwd, *cause, **argv = NULL;
int flags = 0, argc = 0;
u_int px, py, w, h, count = args_count(args);
+ struct args_value *av;
+ struct environ *env = NULL;
if (args_has(args, 'C')) {
server_client_clear_overlay(tc);
} else
args_to_vector(args, &argc, &argv);
+ if (args_has(args, 'e') >= 1) {
+ env = environ_create();
+ av = args_first_value(args, 'e');
+ while (av != NULL) {
+ environ_put(env, av->string, 0);
+ av = args_next_value(av);
+ }
+ }
+
if (args_has(args, 'E') > 1)
flags |= POPUP_CLOSEEXITZERO;
else if (args_has(args, 'E'))
flags |= POPUP_CLOSEEXIT;
if (args_has(args, 'B'))
flags |= POPUP_NOBORDER;
- if (popup_display(flags, item, px, py, w, h, shellcmd, argc, argv, cwd,
- tc, s, NULL, NULL) != 0) {
+ if (popup_display(flags, item, px, py, w, h, env, shellcmd, argc, argv,
+ cwd, tc, s, NULL, NULL) != 0) {
cmd_free_argv(argc, argv);
+ if (env != NULL)
+ environ_free(env);
return (CMD_RETURN_NORMAL);
}
+ if (env != NULL)
+ environ_free(env);
cmd_free_argv(argc, argv);
return (CMD_RETURN_WAIT);
}
-/* $OpenBSD: cmd-if-shell.c,v 1.83 2021/09/15 07:38:30 nicm Exp $ */
+/* $OpenBSD: cmd-if-shell.c,v 1.84 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
if (cdata->client != NULL)
cdata->client->references++;
- if (job_run(shellcmd, 0, NULL, s,
+ if (job_run(shellcmd, 0, NULL, NULL, s,
server_client_get_cwd(cmdq_get_client(item), s), NULL,
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0, -1,
-1) == NULL) {
-/* $OpenBSD: cmd-run-shell.c,v 1.81 2021/09/16 06:39:22 nicm Exp $ */
+/* $OpenBSD: cmd-run-shell.c,v 1.82 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
cmd_run_shell_free(cdata);
return;
}
- if (job_run(cmd, 0, NULL, cdata->s, cdata->cwd, NULL,
+ if (job_run(cmd, 0, NULL, NULL, cdata->s, cdata->cwd, NULL,
cmd_run_shell_callback, cmd_run_shell_free, cdata,
cdata->flags, -1, -1) == NULL)
cmd_run_shell_free(cdata);
-/* $OpenBSD: format.c,v 1.297 2021/10/05 20:15:16 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.298 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
if (force && fj->job != NULL)
job_free(fj->job);
if (force || (fj->job == NULL && fj->last != t)) {
- fj->job = job_run(expanded, 0, NULL, NULL,
+ fj->job = job_run(expanded, 0, NULL, NULL, NULL,
server_client_get_cwd(ft->client, NULL), format_job_update,
format_job_complete, NULL, fj, JOB_NOWAIT, -1, -1);
if (fj->job == NULL) {
-/* $OpenBSD: job.c,v 1.64 2021/10/05 12:49:37 nicm Exp $ */
+/* $OpenBSD: job.c,v 1.65 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
/* Start a job running. */
struct job *
-job_run(const char *cmd, int argc, char **argv, struct session *s,
+job_run(const char *cmd, int argc, char **argv, struct environ *e, struct session *s,
const char *cwd, job_update_cb updatecb, job_complete_cb completecb,
job_free_cb freecb, void *data, int flags, int sx, int sy)
{
* if-shell to decide on default-terminal based on outside TERM.
*/
env = environ_for_session(s, !cfg_finished);
+ if (e != NULL) {
+ environ_copy(e, env);
+ }
sigfillset(&set);
sigprocmask(SIG_BLOCK, &set, &oldset);
-/* $OpenBSD: popup.c,v 1.34 2021/08/17 08:22:44 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.35 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
int
popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
- u_int sy, const char *shellcmd, int argc, char **argv, const char *cwd,
- struct client *c, struct session *s, popup_close_cb cb, void *arg)
+ u_int sy, struct environ *env, const char *shellcmd, int argc, char **argv,
+ const char *cwd, struct client *c, struct session *s, popup_close_cb cb,
+ void *arg)
{
struct popup_data *pd;
u_int jx, jy;
pd->psx = sx;
pd->psy = sy;
- pd->job = job_run(shellcmd, argc, argv, s, cwd,
+ pd->job = job_run(shellcmd, argc, argv, env, s, cwd,
popup_job_update_cb, popup_job_complete_cb, NULL, pd,
JOB_NOWAIT|JOB_PTY|JOB_KEEPWRITE, jx, jy);
pd->ictx = input_init(NULL, job_get_event(pd->job), &pd->palette);
xasprintf(&cmd, "%s %s", editor, path);
if (popup_display(POPUP_INTERNAL|POPUP_CLOSEEXIT, NULL, px, py, sx, sy,
- cmd, 0, NULL, _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) {
+ NULL, cmd, 0, NULL, _PATH_TMP, c, NULL, popup_editor_close_cb, pe) != 0) {
popup_editor_free(pe);
free(cmd);
return (-1);
-.\" $OpenBSD: tmux.1,v 1.859 2021/10/08 14:14:31 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.860 2021/10/11 10:55:30 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 8 2021 $
+.Dd $Mdocdate: October 11 2021 $
.Dt TMUX 1
.Os
.Sh NAME
.Op Fl BCE
.Op Fl c Ar target-client
.Op Fl d Ar start-directory
+.Op Fl e Ar environment
.Op Fl h Ar height
.Op Fl t Ar target-pane
.Op Fl w Ar width
.Fl B
does not surround the popup by a border.
.Pp
+.Fl e
+takes the form
+.Ql VARIABLE=value
+and sets an environment variable for the popup; it may be specified multiple
+times.
+.Pp
The
.Fl C
flag closes any popup on the client.
-/* $OpenBSD: tmux.h,v 1.1143 2021/10/05 12:46:02 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1144 2021/10/11 10:55:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
#define JOB_NOWAIT 0x1
#define JOB_KEEPWRITE 0x2
#define JOB_PTY 0x4
-struct job *job_run(const char *, int, char **, struct session *,
- const char *, job_update_cb, job_complete_cb, job_free_cb,
- void *, int, int, int);
+struct job *job_run(const char *, int, char **, struct environ *,
+ struct session *, const char *, job_update_cb,
+ job_complete_cb, job_free_cb, void *, int, int, int);
void job_free(struct job *);
int job_transfer(struct job *, pid_t *, char *, size_t);
void job_resize(struct job *, u_int, u_int);
typedef void (*popup_close_cb)(int, void *);
typedef void (*popup_finish_edit_cb)(char *, size_t, void *);
int popup_display(int, struct cmdq_item *, u_int, u_int, u_int,
- u_int, const char *, int, char **, const char *,
- struct client *, struct session *, popup_close_cb, void *);
+ u_int, struct environ *, const char *, int, char **,
+ const char *, struct client *, struct session *,
+ popup_close_cb, void *);
int popup_editor(struct client *, const char *, size_t,
popup_finish_edit_cb, void *);
-/* $OpenBSD: window-copy.c,v 1.330 2021/08/20 20:04:22 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.331 2021/10/11 10:55:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
if (cmd == NULL || *cmd == '\0')
cmd = options_get_string(global_options, "copy-command");
if (cmd != NULL && *cmd != '\0') {
- job = job_run(cmd, 0, NULL, s, NULL, NULL, NULL, NULL, NULL,
- JOB_NOWAIT, -1, -1);
+ job = job_run(cmd, 0, NULL, NULL, s, NULL, NULL, NULL, NULL,
+ NULL, JOB_NOWAIT, -1, -1);
bufferevent_write(job_get_event(job), buf, *len);
}
return (buf);