diff --git a/src/parse_productions.cpp b/src/parse_productions.cpp index f752df8f10ab..84745ff1055d 100644 --- a/src/parse_productions.cpp +++ b/src/parse_productions.cpp @@ -314,6 +314,14 @@ RESOLVE(block_header) { } RESOLVE(decorated_statement) { + // and/or are typically parsed in job_conjunction at the beginning of a job + // However they may be reached here through e.g. true && and false. + // Refuse to parse them as a command except for --help. See #6089. + if ((token1.keyword == parse_keyword_and || token1.keyword == parse_keyword_or) && + !token2.is_help_argument) { + return NO_PRODUCTION; + } + // If this is e.g. 'command --help' then the command is 'command' and not a decoration. If the // second token is not a string, then this is a naked 'command' and we should execute it as // undecorated. diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index c840f29ed33c..b2f4eec6c4df 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -156,6 +156,7 @@ static wcstring token_type_user_presentable_description( switch (type) { // Hackish. We only support the following types. + case symbol_decorated_statement: case symbol_statement: return L"a command"; case symbol_argument: