summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-06-05 23:02:26 +0100
committerThomas Adam <thomas@xteddy.org>2019-06-05 23:02:26 +0100
commitc91680822df84f6db2f8ce650e457d59d37f3856 (patch)
treec2ff1cb796bbaeecc26544beeb1666fdb39ecae5
parent37bb993f539012a65ea44e0e35f8cf88f27dfe19 (diff)
parent8f40796f05f2db0ff8b2c9231054b62b511a7ba0 (diff)
Merge branch 'obsd-master'
-rw-r--r--cfg.c1
-rw-r--r--cmd-parse.y17
-rw-r--r--cmd-source-file.c6
-rw-r--r--tmux.14
-rw-r--r--tmux.h1
5 files changed, 26 insertions, 3 deletions
diff --git a/cfg.c b/cfg.c
index 18386b56..009c748c 100644
--- a/cfg.c
+++ b/cfg.c
@@ -126,6 +126,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
pi.flags = flags;
pi.file = path;
pi.line = 1;
+ pi.item = item;
pr = cmd_parse_from_file(f, &pi);
fclose(f);
diff --git a/cmd-parse.y b/cmd-parse.y
index e27cdcd8..a7c12f62 100644
--- a/cmd-parse.y
+++ b/cmd-parse.y
@@ -76,6 +76,8 @@ static char *cmd_parse_get_error(const char *, u_int, const char *);
static void cmd_parse_free_command(struct cmd_parse_command *);
static struct cmd_parse_commands *cmd_parse_new_commands(void);
static void cmd_parse_free_commands(struct cmd_parse_commands *);
+static void cmd_parse_print_commands(struct cmd_parse_input *, u_int,
+ struct cmd_list *);
%}
@@ -498,6 +500,19 @@ cmd_parse_get_error(const char *file, u_int line, const char *error)
}
static void
+cmd_parse_print_commands(struct cmd_parse_input *pi, u_int line,
+ struct cmd_list *cmdlist)
+{
+ char *s;
+
+ if (pi->item != NULL && (pi->flags & CMD_PARSE_VERBOSE)) {
+ s = cmd_list_print(cmdlist, 0);
+ cmdq_print(pi->item, "%u: %s", line, s);
+ free(s);
+ }
+}
+
+static void
cmd_parse_free_command(struct cmd_parse_command *cmd)
{
free(cmd->name);
@@ -653,6 +668,7 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
if (cmdlist == NULL || cmd->line != line) {
if (cmdlist != NULL) {
+ cmd_parse_print_commands(pi, line, cmdlist);
cmd_list_move(result, cmdlist);
cmd_list_free(cmdlist);
}
@@ -672,6 +688,7 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
cmd_list_append(cmdlist, add);
}
if (cmdlist != NULL) {
+ cmd_parse_print_commands(pi, line, cmdlist);
cmd_list_move(result, cmdlist);
cmd_list_free(cmdlist);
}
diff --git a/cmd-source-file.c b/cmd-source-file.c
index 38aede0c..2e01ae67 100644
--- a/cmd-source-file.c
+++ b/cmd-source-file.c
@@ -37,8 +37,8 @@ const struct cmd_entry cmd_source_file_entry = {
.name = "source-file",
.alias = "source",
- .args = { "nq", 1, -1 },
- .usage = "[-nq] path ...",
+ .args = { "nqv", 1, -1 },
+ .usage = "[-nqv] path ...",
.flags = 0,
.exec = cmd_source_file_exec
@@ -62,6 +62,8 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
flags |= CMD_PARSE_QUIET;
if (args_has(args, 'n'))
flags |= CMD_PARSE_PARSEONLY;
+ if (args_has(args, 'v'))
+ flags |= CMD_PARSE_VERBOSE;
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB);
retval = CMD_RETURN_NORMAL;
diff --git a/tmux.1 b/tmux.1
index 0138c5bd..fe27105d 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1256,7 +1256,7 @@ and
.Fl T
show debugging information about jobs and terminals.
.It Xo Ic source-file
-.Op Fl nq
+.Op Fl nqv
.Ar path
.Ar ...
.Xc
@@ -1274,6 +1274,8 @@ does not exist.
With
.Fl n ,
the file is parsed but no commands are executed.
+.Fl v
+shows the parsed commands and line numbers if possible.
.It Ic start-server
.D1 (alias: Ic start )
Start the
diff --git a/tmux.h b/tmux.h
index c66f9a40..5adb8545 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1326,6 +1326,7 @@ struct cmd_parse_input {
#define CMD_PARSE_QUIET 0x1
#define CMD_PARSE_PARSEONLY 0x2
#define CMD_PARSE_NOALIAS 0x4
+#define CMD_PARSE_VERBOSE 0x8
const char *file;
u_int line;