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++;
}
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);

View File

@@ -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))
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));

11
cmd.c
View File

@@ -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);

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 *);
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 *);