diff --git a/bshell.core/cmdlets/foreach-object.c b/bshell.core/cmdlets/foreach-object.c index e979eec..4801eb4 100644 --- a/bshell.core/cmdlets/foreach-object.c +++ b/bshell.core/cmdlets/foreach-object.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,9 @@ static enum bshell_status process_record( } bshell_runtime_push_scope(rt, p->f_block); - bshell_variable *item = bshell_runtime_define_var(rt, "_"); + bshell_variable *item = bshell_runtime_scope_define_variable( + bshell_runtime_get_current_scope(rt), + "_"); bshell_variable_set_value(item, in); fx_value out = bshell_runtime_eval(rt); bshell_runtime_pop_scope(rt);