diff --git a/src/cmd/ksh93/bltins/typeset.c b/src/cmd/ksh93/bltins/typeset.c index 4ddeb2789..7dc246fd9 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 && nv_search(name,shp->fun_base,0)) + else if(troot==shp->fun_tree && troot!=shp->fun_base) nv_open(name,troot,NV_NOSCOPE); /* create dummy virtual subshell node without NV_FUNCTION attribute */ } sh_popcontext(shp,&buff); diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index bde31f1e6..2ba5cbe90 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -693,6 +693,12 @@ got=$( [[ $got == "$exp" ]] || err_exit 'unset -f fails in forked subshells if a function is defined before forking' \ "(expected $(printf %q "$exp"), got $(printf %q "$got"))" +# function set in subshell, unset in subshell of that subshell +exp='*: f: not found' +got=$( f() { echo WRONG; }; ( unset -f f; PATH=/dev/null f 2>&1 ) ) +[[ $got == $exp ]] || err_exit 'unset -f fails in sub-subshell on function set in subshell' \ + "(expected match of $(printf %q "$exp"), got $(printf %q "$got"))" + # ====== # Unsetting or redefining aliases within subshells