diff --git a/arguments.c b/arguments.c index b1aa54eb8..8ec3123ac 100644 --- a/arguments.c +++ b/arguments.c @@ -114,8 +114,10 @@ args_value_as_string(struct args_value *value) case ARGS_NONE: return (""); case ARGS_COMMANDS: - if (value->cached == NULL) - value->cached = cmd_parse_print(value->cmd, 0); + if (value->cached == NULL) { + value->cached = cmd_parse_print(value->cmd, + CMD_PARSE_PRINT_RAW); + } return (value->cached); case ARGS_STRING: return (value->string); diff --git a/cmd-parse.y b/cmd-parse.y index 4c3a83014..d445cebb8 100644 --- a/cmd-parse.y +++ b/cmd-parse.y @@ -1174,9 +1174,9 @@ cmd_parse_print_string(char **buf, struct cmd_parse_node *string) } static const char * -cmd_parse_print_separator(u_int depth) +cmd_parse_print_separator(u_int depth, int flags) { - if (depth == 0) + if (depth == 0 && (~flags & CMD_PARSE_PRINT_RAW)) return (" \\; "); return (" ; "); } @@ -1318,7 +1318,7 @@ cmd_parse_print_sequence(char **buf, struct cmd_parse_node *seq, u_int depth, int flags) { struct cmd_parse_node *child, *first_child; - const char *sep = cmd_parse_print_separator(depth); + const char *sep = cmd_parse_print_separator(depth, flags); int first = 1; /* @@ -1343,6 +1343,7 @@ char * cmd_parse_print(struct cmd_parse_tree *tree, int flags) { struct cmd_parse_node *root = tree->root, *child; + const char *sep = cmd_parse_print_separator(0, flags); char *buf = NULL; int first = 1; @@ -1351,7 +1352,7 @@ cmd_parse_print(struct cmd_parse_tree *tree, int flags) if (flags & CMD_PARSE_PRINT_MULTILINE) cmd_parse_strcat(&buf, "\n"); else - cmd_parse_strcat(&buf, " \\; "); + cmd_parse_strcat(&buf, "%s", sep); } first = 0; cmd_parse_print_sequence(&buf, child, 0, flags); diff --git a/tmux-parser.h b/tmux-parser.h index cfd441561..7bb0abe7e 100644 --- a/tmux-parser.h +++ b/tmux-parser.h @@ -72,6 +72,7 @@ enum cmd_parse_node_type { }; #define CMD_PARSE_PRINT_MULTILINE 0x1 +#define CMD_PARSE_PRINT_RAW 0x2 struct cmd_parse_tree *cmd_parse_from_file(FILE *, struct cmd_parse_input *, char **);