From 295cce2c6d1ab41c5388b07fb545a0d5060dc73f Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sat, 24 Apr 2021 16:27:29 +0100 Subject: [PATCH] Improve fix for 'unset -f' in sub-subshell (re: 07faf384, 13c57e4b) src/cmd/ksh93/bltins/typeset.c: - Removing the nv_search() call altogether was actually not neccessary, I was just searching the wrong tree: instead of sh.fun_base, simply search the current sh.fun_tree which has a view to all the layered parent subshell copes. It is not going to find it in the current subshell tree but will find it in one of the parent trees if it exists. The cost of an unnecessary dummy is negligible, but so is the cost of this search, and doing it is more correct. --- src/cmd/ksh93/bltins/typeset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index 7dc246fd9..418415933 100644 --- a/src/cmd/ksh93/bltins/typeset.c +++ b/src/cmd/ksh93/bltins/typeset.c @@ -1398,7 +1398,7 @@ static int unall(int argc, char **argv, register Dt_t *troot, Shell_t* shp) } else if(troot==shp->alias_tree) r = 1; - else if(troot==shp->fun_tree && troot!=shp->fun_base) + else if(troot==shp->fun_tree && troot!=shp->fun_base && nv_search(name,shp->fun_tree,0)) nv_open(name,troot,NV_NOSCOPE); /* create dummy virtual subshell node without NV_FUNCTION attribute */ } sh_popcontext(shp,&buff);