diff --git a/src/funcs.c b/src/funcs.c index bc0abf26..5812a60c 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -3993,6 +3993,7 @@ FEval(func_info *info) { expr_node *n; int r; + int run_was_enabled = 0; ASSERT_TYPE(0, STR_TYPE); char const *e = ARGSTR(0); @@ -4004,9 +4005,14 @@ FEval(func_info *info) } /* Disable shell() command in eval */ - RunDisabled |= RUN_IN_EVAL; + if (! (RunDisabled & RUN_IN_EVAL)) { + run_was_enabled = 1; + RunDisabled |= RUN_IN_EVAL; + } r = evaluate_expr_node(n, NULL, &(info->retval), &(info->nonconst)); - RunDisabled &= ~RUN_IN_EVAL; + if (run_was_enabled) { + RunDisabled &= ~RUN_IN_EVAL; + } free_expr_tree(n); return r; } diff --git a/tests/test.cmp b/tests/test.cmp index 4d34f743..3e81b834 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -16542,11 +16542,18 @@ Entering UserFN i() shell("echo foo") => "foo" Leaving UserFN i() => "foo" FUNSET i +set a "eval(\"1\")+ shell(\"ls\")" +set b eval(a) +a => "eval(\"1\")+ shell(\"ls\")" +eval("eval(\"1\")+ shell(\"ls\")") => eval("1") => 1 +shell("ls") => RUN disabled +../tests/test.rem(1587): shell(): RUN disabled +RUN disabled DEBUG -x DEBUG -e -../tests/test.rem(1593): eval(): Too many recursive function calls +../tests/test.rem(1595): eval(): Too many recursive function calls Base: 1991-02-09 Base: 1991-02-09 Variable hash table statistics: diff --git a/tests/test.rem b/tests/test.rem index 94ff0626..e197754e 100644 --- a/tests/test.rem +++ b/tests/test.rem @@ -1583,6 +1583,8 @@ set a i() set a eval("i()") set a i() FUNSET i +set a "eval(\"1\")+ shell(\"ls\")" +set b eval(a) DEBUG -x