Make -v to source-file pass through to subsequent source-file commands,

GitHub issue 4216.
This commit is contained in:
nicm
2025-11-18 08:42:09 +00:00
parent b52dcff745
commit 2a3ec87887
4 changed files with 19 additions and 6 deletions

View File

@@ -849,7 +849,7 @@ cmd_parse_build_command(struct cmd_parse_command *cmd,
count++; 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) { if (add == NULL) {
pr->status = CMD_PARSE_ERROR; pr->status = CMD_PARSE_ERROR;
pr->error = cmd_parse_get_error(pi->file, pi->line, cause); pr->error = cmd_parse_get_error(pi->file, pi->line, cause);

View File

@@ -167,7 +167,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
char *pattern, *cwd, *expanded = NULL; char *pattern, *cwd, *expanded = NULL;
const char *path, *error; const char *path, *error;
glob_t g; glob_t g;
int result; int result, parse_flags;
u_int i, j; u_int i, j;
if (c == NULL) { if (c == NULL) {
@@ -193,8 +193,11 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
cdata->flags |= CMD_PARSE_QUIET; cdata->flags |= CMD_PARSE_QUIET;
if (args_has(args, 'n')) if (args_has(args, 'n'))
cdata->flags |= CMD_PARSE_PARSEONLY; cdata->flags |= CMD_PARSE_PARSEONLY;
if (args_has(args, 'v') && (c == NULL || ~c->flags & CLIENT_CONTROL)) if (c == NULL || ~c->flags & CLIENT_CONTROL) {
cdata->flags |= CMD_PARSE_VERBOSE; 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)); cwd = cmd_source_file_quote_for_glob(server_client_get_cwd(c, NULL));

11
cmd.c
View File

@@ -221,6 +221,7 @@ struct cmd {
char *file; char *file;
u_int line; u_int line;
int parse_flags;
TAILQ_ENTRY(cmd) qentry; TAILQ_ENTRY(cmd) qentry;
}; };
@@ -413,6 +414,13 @@ cmd_get_source(struct cmd *cmd, const char **file, u_int *line)
*line = cmd->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. */ /* Look for an alias for a command. */
char * char *
cmd_get_alias(const char *name) cmd_get_alias(const char *name)
@@ -497,7 +505,7 @@ ambiguous:
/* Parse a single command from an argument vector. */ /* Parse a single command from an argument vector. */
struct cmd * struct cmd *
cmd_parse(struct args_value *values, u_int count, const char *file, u_int line, 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; const struct cmd_entry *entry;
struct cmd *cmd; 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 = xcalloc(1, sizeof *cmd);
cmd->entry = entry; cmd->entry = entry;
cmd->args = args; cmd->args = args;
cmd->parse_flags = parse_flags;
if (file != NULL) if (file != NULL)
cmd->file = xstrdup(file); cmd->file = xstrdup(file);

3
tmux.h
View File

@@ -2667,7 +2667,8 @@ const struct cmd_entry *cmd_get_entry(struct cmd *);
struct args *cmd_get_args(struct cmd *); struct args *cmd_get_args(struct cmd *);
u_int cmd_get_group(struct cmd *); u_int cmd_get_group(struct cmd *);
void cmd_get_source(struct cmd *, const char **, u_int *); 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 **); char **);
struct cmd *cmd_copy(struct cmd *, int, char **); struct cmd *cmd_copy(struct cmd *, int, char **);
void cmd_free(struct cmd *); void cmd_free(struct cmd *);