diff --git a/src/highlight.cpp b/src/highlight.cpp index 53cbedd52..7536bea41 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -467,9 +467,8 @@ bool autosuggest_validate_from_history(const history_item_t &item, } // Not handled specially so handle it here. - bool cmd_ok = builtin_exists(parsed_command) - || function_exists_no_autoload(parsed_command) - || path_get_path(parsed_command, nullptr, ctx.vars); + bool cmd_ok = builtin_exists(parsed_command) || function_exists_no_autoload(parsed_command) || + path_get_path(parsed_command, nullptr, ctx.vars); if (cmd_ok) { const path_list_t &paths = item.get_required_paths(); diff --git a/src/input.cpp b/src/input.cpp index 9445c8673..169722c41 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -530,12 +530,10 @@ char_event_t inputter_t::readch(bool allow_commands) { case readline_cmd_t::func_or: { // If previous function has right status, we keep reading tokens if (evt.get_readline() == readline_cmd_t::func_and) { - if (function_status_) - return readch(); + if (function_status_) return readch(); } else { assert(evt.get_readline() == readline_cmd_t::func_or); - if (!function_status_) - return readch(); + if (!function_status_) return readch(); } // Else we flush remaining tokens do { diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 0a4daf14d..d2cea3634 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -1222,47 +1222,43 @@ parser_test_error_bits_t parse_util_detect_errors(const ast::ast_t &ast, const w // Verify no variable expansions. wcstring storage; - for (const node_t &node : ast) { - if (const job_continuation_t *jc = node.try_as()) { - // Somewhat clumsy way of checking for a statement without source in a pipeline. - // See if our pipe has source but our statement does not. - if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) { - has_unclosed_pipe = true; - } - } else if (const argument_t *arg = node.try_as()) { - const wcstring &arg_src = arg->source(buff_src, &storage); - res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors); - } else if (const ast::job_t *job = node.try_as()) { - // Disallow background in the following cases: - // - // foo & ; and bar - // foo & ; or bar - // if foo & ; end - // while foo & ; end - // If it's not a background job, nothing to do. - if (job->bg) { - errored |= detect_errors_in_backgrounded_job(*job, out_errors); - } - } else if (const ast::decorated_statement_t *stmt = - node.try_as()) { - errored |= - detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors); - } else if (const auto *block = node.try_as()) { - // If our 'end' had no source, we are unsourced. - if (block->end.unsourced) has_unclosed_block = true; - errored |= - detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors); - } else if (const auto *ifs = node.try_as()) { - // If our 'end' had no source, we are unsourced. - if (ifs->end.unsourced) has_unclosed_block = true; - errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors); - } else if (const auto *switchs = node.try_as()) { - // If our 'end' had no source, we are unsourced. - if (switchs->end.unsourced) has_unclosed_block = true; - errored |= - detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors); + for (const node_t &node : ast) { + if (const job_continuation_t *jc = node.try_as()) { + // Somewhat clumsy way of checking for a statement without source in a pipeline. + // See if our pipe has source but our statement does not. + if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) { + has_unclosed_pipe = true; } + } else if (const argument_t *arg = node.try_as()) { + const wcstring &arg_src = arg->source(buff_src, &storage); + res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors); + } else if (const ast::job_t *job = node.try_as()) { + // Disallow background in the following cases: + // + // foo & ; and bar + // foo & ; or bar + // if foo & ; end + // while foo & ; end + // If it's not a background job, nothing to do. + if (job->bg) { + errored |= detect_errors_in_backgrounded_job(*job, out_errors); + } + } else if (const ast::decorated_statement_t *stmt = node.try_as()) { + errored |= detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors); + } else if (const auto *block = node.try_as()) { + // If our 'end' had no source, we are unsourced. + if (block->end.unsourced) has_unclosed_block = true; + errored |= detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors); + } else if (const auto *ifs = node.try_as()) { + // If our 'end' had no source, we are unsourced. + if (ifs->end.unsourced) has_unclosed_block = true; + errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors); + } else if (const auto *switchs = node.try_as()) { + // If our 'end' had no source, we are unsourced. + if (switchs->end.unsourced) has_unclosed_block = true; + errored |= detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors); } + } if (errored) res |= PARSER_TEST_ERROR;