diff --git a/NEWS b/NEWS index 71067751e..862a7b6ea 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,10 @@ Any uppercase BUG_* names are modernish shell bug IDs. part uniquely identified it so the menu only showed one item. Details: https://www.mail-archive.com/ast-users@lists.research.att.com/msg00436.html +- A bug with ${.sh.fun} in combination with the DEBUG trap has been fixed. + The ${.sh.fun} variable wrongly continued to contain the name of the last + function executed by the DEBUG trap after the trap action completed. + 2021-02-21: - Fixed: The way that SIGWINCH was handled (i.e. the signal emitted when the diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index ac23276fa..3f045ddb7 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -697,8 +697,6 @@ int sh_debug(Shell_t *shp, const char *trap, const char *name, const char *subsc shp->indebug = 0; if(shp->st.cmdname) error_info.id = shp->st.cmdname; - nv_putval(SH_PATHNAMENOD,shp->st.filename,NV_NOFREE); - nv_putval(SH_FUNNAMENOD,shp->st.funname,NV_NOFREE); shp->st = savst; if(sav != stkptr(stkp,0)) stkset(stkp,sav,offset); diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index 531461315..24aa4e1ed 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -1192,5 +1192,11 @@ got=$(FPATH=$tmp "$SHELL" ./lineno_autoload 2>&1) [[ $got == "$exp" ]] || err_exit 'Regression in $LINENO and/or error messages.' \ $'Diff follows:\n'"$(diff -u <(print -r -- "$exp") <(print -r -- "$got") | sed $'s/^/\t| /')" +# ====== +# Before 2021-02-26, the DEBUG trap corrupted ${.sh.fun} +unset .sh.fun +got=$(some_func() { :; }; trap some_func DEBUG; trap - DEBUG; print -r "${.sh.fun}") +[[ -z $got ]] || err_exit "\${.sh.fun} leaks out of DEBUG trap (got $(printf %q "$got"))" + # ====== exit $((Errors<125?Errors:125))