summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-if-shell.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-10-09 08:06:51 +0000
committernicm <nicm@openbsd.org>2016-10-09 08:06:51 +0000
commit10c3daba99e93a4a7729d07c0d02ba230289d3e1 (patch)
treee969cefef7a7d6285a1d268af9eba885c15d014c /usr.bin/tmux/cmd-if-shell.c
parentHandle NULL window or session for user options. (diff)
downloadwireguard-openbsd-10c3daba99e93a4a7729d07c0d02ba230289d3e1.tar.xz
wireguard-openbsd-10c3daba99e93a4a7729d07c0d02ba230289d3e1.zip
Pass file/line to new command for if-shell so that errors appear
sensibly.
Diffstat (limited to 'usr.bin/tmux/cmd-if-shell.c')
-rw-r--r--usr.bin/tmux/cmd-if-shell.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c
index cdf8545635c..8a75bc57677 100644
--- a/usr.bin/tmux/cmd-if-shell.c
+++ b/usr.bin/tmux/cmd-if-shell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-if-shell.c,v 1.43 2016/04/29 17:12:12 nicm Exp $ */
+/* $OpenBSD: cmd-if-shell.c,v 1.44 2016/10/09 08:06:51 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -50,6 +50,9 @@ const struct cmd_entry cmd_if_shell_entry = {
};
struct cmd_if_shell_data {
+ char *file;
+ u_int line;
+
char *cmd_if;
char *cmd_else;
@@ -106,7 +109,11 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL);
}
- cdata = xmalloc(sizeof *cdata);
+ cdata = xcalloc(1, sizeof *cdata);
+ if (self->file != NULL) {
+ cdata->file = xstrdup(self->file);
+ cdata->line = self->line;
+ }
cdata->cmd_if = xstrdup(args->argv[1]);
if (args->argc == 3)
@@ -148,7 +155,8 @@ cmd_if_shell_callback(struct job *job)
if (cmd == NULL)
return;
- if (cmd_string_parse(cmd, &cmdlist, NULL, 0, &cause) != 0) {
+ if (cmd_string_parse(cmd, &cmdlist, cdata->file, cdata->line,
+ &cause) != 0) {
if (cause != NULL) {
cmdq_error(cmdq, "%s", cause);
free(cause);
@@ -184,6 +192,8 @@ cmd_if_shell_done(struct cmd_q *cmdq1)
free(cdata->cmd_else);
free(cdata->cmd_if);
+
+ free(cdata->file);
free(cdata);
}
@@ -201,5 +211,7 @@ cmd_if_shell_free(void *data)
free(cdata->cmd_else);
free(cdata->cmd_if);
+
+ free(cdata->file);
free(cdata);
}