From 2a3ec87887657912531724812e9370f34d6f93c8 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Nov 2025 08:42:09 +0000 Subject: [PATCH] Make -v to source-file pass through to subsequent source-file commands, GitHub issue 4216. --- cmd-parse.y | 2 +- cmd-source-file.c | 9 ++++++--- cmd.c | 11 ++++++++++- tmux.h | 3 ++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cmd-parse.y b/cmd-parse.y index 843403a4..4cd8a420 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -849,7 +849,7 @@ cmd_parse_build_command(struct cmd_parse_command *cmd, count++; } - add = cmd_parse(values, count, pi->file, pi->line, &cause); + add = cmd_parse(values, count, pi->file, pi->line, pi->flags, &cause); if (add == NULL) { pr->status = CMD_PARSE_ERROR; pr->error = cmd_parse_get_error(pi->file, pi->line, cause); diff --git a/cmd-source-file.c b/cmd-source-file.c index 8f8b2504..cbd53960 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -167,7 +167,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) char *pattern, *cwd, *expanded = NULL; const char *path, *error; glob_t g; - int result; + int result, parse_flags; u_int i, j; if (c == NULL) { @@ -193,8 +193,11 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item) cdata->flags |= CMD_PARSE_QUIET; if (args_has(args, 'n')) cdata->flags |= CMD_PARSE_PARSEONLY; - if (args_has(args, 'v') && (c == NULL || ~c->flags & CLIENT_CONTROL)) - cdata->flags |= CMD_PARSE_VERBOSE; + if (c == NULL || ~c->flags & CLIENT_CONTROL) { + parse_flags = cmd_get_parse_flags(self); + if (args_has(args, 'v') || (parse_flags & CMD_PARSE_VERBOSE)) + cdata->flags |= CMD_PARSE_VERBOSE; + } cwd = cmd_source_file_quote_for_glob(server_client_get_cwd(c, NULL)); diff --git a/cmd.c b/cmd.c index 61519f3f..f02aa625 100644 --- a/cmd.c +++ b/cmd.c @@ -221,6 +221,7 @@ struct cmd { char *file; u_int line; + int parse_flags; TAILQ_ENTRY(cmd) qentry; }; @@ -413,6 +414,13 @@ cmd_get_source(struct cmd *cmd, const char **file, u_int *line) *line = cmd->line; } +/* Get parse flags for command. */ +int +cmd_get_parse_flags(struct cmd *cmd) +{ + return (cmd->parse_flags); +} + /* Look for an alias for a command. */ char * cmd_get_alias(const char *name) @@ -497,7 +505,7 @@ ambiguous: /* Parse a single command from an argument vector. */ struct cmd * cmd_parse(struct args_value *values, u_int count, const char *file, u_int line, - char **cause) + int parse_flags, char **cause) { const struct cmd_entry *entry; struct cmd *cmd; @@ -526,6 +534,7 @@ cmd_parse(struct args_value *values, u_int count, const char *file, u_int line, cmd = xcalloc(1, sizeof *cmd); cmd->entry = entry; cmd->args = args; + cmd->parse_flags = parse_flags; if (file != NULL) cmd->file = xstrdup(file); diff --git a/tmux.h b/tmux.h index 6aa9bc57..99b80c68 100644 --- a/tmux.h +++ b/tmux.h @@ -2667,7 +2667,8 @@ const struct cmd_entry *cmd_get_entry(struct cmd *); struct args *cmd_get_args(struct cmd *); u_int cmd_get_group(struct cmd *); void cmd_get_source(struct cmd *, const char **, u_int *); -struct cmd *cmd_parse(struct args_value *, u_int, const char *, u_int, +int cmd_get_parse_flags(struct cmd *); +struct cmd *cmd_parse(struct args_value *, u_int, const char *, u_int, int, char **); struct cmd *cmd_copy(struct cmd *, int, char **); void cmd_free(struct cmd *);