summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-parse.y
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-01-27 08:23:43 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-01-27 08:23:43 +0000
commit1cc38d9abc126197bae007533ca822b78de26390 (patch)
treef04a0750a8db38e4ef3d1e1a873d14ca401538b2 /usr.bin/tmux/cmd-parse.y
parent9eb934abe606de3eb0db713a571cbb221b1998da (diff)
Change so that assignments may be specified alone - a command isn't
required. GitHub issue 2062.
Diffstat (limited to 'usr.bin/tmux/cmd-parse.y')
-rw-r--r--usr.bin/tmux/cmd-parse.y36
1 files changed, 25 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y
index ba00fd9de4f..d0a8fffc4ea 100644
--- a/usr.bin/tmux/cmd-parse.y
+++ b/usr.bin/tmux/cmd-parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-parse.y,v 1.21 2019/12/12 15:01:54 nicm Exp $ */
+/* $OpenBSD: cmd-parse.y,v 1.22 2020/01/27 08:23:42 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -133,7 +133,12 @@ statements : statement '\n'
free($2);
}
-statement : condition
+statement : /* empty */
+ {
+ $$ = xmalloc (sizeof *$$);
+ TAILQ_INIT($$);
+ }
+ | condition
{
struct cmd_parse_state *ps = &parse_state;
@@ -144,11 +149,6 @@ statement : condition
cmd_parse_free_commands($1);
}
}
- | assignment
- {
- $$ = xmalloc (sizeof *$$);
- TAILQ_INIT($$);
- }
| commands
{
struct cmd_parse_state *ps = &parse_state;
@@ -194,8 +194,10 @@ expanded : format
free($1);
}
-assignment : /* empty */
- | EQUALS
+optional_assignment : /* empty */
+ | assignment
+
+assignment : EQUALS
{
struct cmd_parse_state *ps = &parse_state;
int flags = ps->input->flags;
@@ -372,7 +374,15 @@ commands : command
$$ = $1;
}
-command : assignment TOKEN
+command : assignment
+ {
+ struct cmd_parse_state *ps = &parse_state;
+
+ $$ = xcalloc(1, sizeof *$$);
+ $$->name = NULL;
+ $$->line = ps->input->line;
+ }
+ | optional_assignment TOKEN
{
struct cmd_parse_state *ps = &parse_state;
@@ -381,7 +391,7 @@ command : assignment TOKEN
$$->line = ps->input->line;
}
- | assignment TOKEN arguments
+ | optional_assignment TOKEN arguments
{
struct cmd_parse_state *ps = &parse_state;
@@ -631,6 +641,8 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
* command list.
*/
TAILQ_FOREACH_SAFE(cmd, cmds, entry, next) {
+ if (cmd->name == NULL)
+ continue;
alias = cmd_get_alias(cmd->name);
if (alias == NULL)
continue;
@@ -676,6 +688,8 @@ cmd_parse_build_commands(struct cmd_parse_commands *cmds,
*/
result = cmd_list_new();
TAILQ_FOREACH(cmd, cmds, entry) {
+ if (cmd->name == NULL)
+ continue;
log_debug("%s: %u %s", __func__, cmd->line, cmd->name);
cmd_log_argv(cmd->argc, cmd->argv, __func__);