fix minify single block for some situations

This commit is contained in:
zawwz 2021-07-24 08:41:32 +02:00
parent 8c63b9a35e
commit f8b5e04423
2 changed files with 5 additions and 2 deletions

View file

@ -455,7 +455,7 @@ block* do_one_minify_single_block(block* in)
ret = l->cls[0]->pls[0]->cmds[0];
// if is a subshell and has some env set: don't remove it
if(in->type == _obj::block_subshell && has_env_set(in))
if(in->type == _obj::block_subshell && has_env_set(ret))
return nullptr;
return ret;
@ -485,6 +485,9 @@ bool r_minify_single_block(_obj* in)
// replace value
delete t->cmds[i];
t->cmds[i] = ret;
recurse(r_minify_single_block, in);
return false;
}
}
}; break;

View file

@ -140,7 +140,7 @@ bool possibly_expands(arglist* in)
bool cmd::has_var_assign()
{
if(this->args->size() == 0)
if(this->args == nullptr || this->args->size() == 0)
{
return this->var_assigns.size()>0;
}