summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-parse.y
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-01-28 13:10:15 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-01-28 13:10:15 +0000
commit9fedcd33589f01c1c73462dda560f06ff26572fc (patch)
tree039a38cb893bebd4cd2dc1549c71381c54673d1d /usr.bin/tmux/cmd-parse.y
parent7378f04882677d2e51ffc7f7ed96cc72c949717b (diff)
Ignore empty commands rather than adding them to the command list rather
than trying to skip them later, fixes problem reported by M Kelly.
Diffstat (limited to 'usr.bin/tmux/cmd-parse.y')
-rw-r--r--usr.bin/tmux/cmd-parse.y12
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y
index d0a8fffc4ea..19840ea55da 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.22 2020/01/27 08:23:42 nicm Exp $ */
+/* $OpenBSD: cmd-parse.y,v 1.23 2020/01/28 13:10:14 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -341,7 +341,8 @@ commands : command
struct cmd_parse_state *ps = &parse_state;
$$ = cmd_parse_new_commands();
- if (ps->scope == NULL || ps->scope->flag)
+ if ($1->name != NULL &&
+ (ps->scope == NULL || ps->scope->flag))
TAILQ_INSERT_TAIL($$, $1, entry);
else
cmd_parse_free_command($1);
@@ -360,7 +361,8 @@ commands : command
{
struct cmd_parse_state *ps = &parse_state;
- if (ps->scope == NULL || ps->scope->flag) {
+ if ($3->name != NULL &&
+ (ps->scope == NULL || ps->scope->flag)) {
$$ = $1;
TAILQ_INSERT_TAIL($$, $3, entry);
} else {
@@ -641,8 +643,6 @@ 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;
@@ -688,8 +688,6 @@ 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__);