From f8b5e04423383f1eae23859a1bd74350c888db2a Mon Sep 17 00:00:00 2001 From: zawwz Date: Sat, 24 Jul 2021 08:41:32 +0200 Subject: [PATCH] fix minify single block for some situations --- src/minify.cpp | 5 ++++- src/struc_helper.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/minify.cpp b/src/minify.cpp index 4a97000..e28ae7d 100644 --- a/src/minify.cpp +++ b/src/minify.cpp @@ -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; diff --git a/src/struc_helper.cpp b/src/struc_helper.cpp index 1f44bff..2c26ee2 100644 --- a/src/struc_helper.cpp +++ b/src/struc_helper.cpp @@ -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; }