mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 10:01:14 -03:00
Disallow backgrounding in conditionals and before and/or bool statements
Fixes #1136
This commit is contained in:
@@ -1649,6 +1649,30 @@ parse_node_tree_t::parse_node_list_t parse_node_tree_t::specific_statements_for_
|
||||
return result;
|
||||
}
|
||||
|
||||
enum parse_bool_statement_type_t parse_node_tree_t::statement_boolean_type(const parse_node_t &node)
|
||||
{
|
||||
assert(node.type == symbol_boolean_statement);
|
||||
switch (node.production_idx)
|
||||
{
|
||||
// These magic numbers correspond to productions for boolean_statement
|
||||
case 0:
|
||||
return parse_bool_and;
|
||||
|
||||
case 1:
|
||||
return parse_bool_or;
|
||||
|
||||
case 2:
|
||||
return parse_bool_not;
|
||||
|
||||
default:
|
||||
{
|
||||
fprintf(stderr, "Unexpected production in boolean statement\n");
|
||||
PARSER_DIE();
|
||||
return (enum parse_bool_statement_type_t)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) const
|
||||
{
|
||||
assert(job.type == symbol_job);
|
||||
@@ -1657,7 +1681,8 @@ bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) cons
|
||||
const parse_node_t *opt_background = get_child(job, 2, symbol_optional_background);
|
||||
if (opt_background != NULL)
|
||||
{
|
||||
assert(opt_background->production_idx <= 1);
|
||||
// We may get the value -1 if the node is not yet materialized (i.e. an incomplete parse tree)
|
||||
assert(opt_background->production_idx == uint8_t(-1) || opt_background->production_idx <= 1);
|
||||
result = (opt_background->production_idx == 1);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user