From 40de1e92b07200d0330e66cf1fa9dacc5ab2c99e Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 24 Nov 2021 06:59:39 +0100 Subject: [PATCH] [1.0 release prep] Block namespace defs in ksh functions In 93v-/ksh2020, namespace defs in any function are a syntax error. This commit blocks namespace defs for ksh functions only, at the execution level. This follows some of AT&T original intention while working around some of the known bugs with namespaces. Related: https://github.com/ksh93/ksh/issues/325 --- src/cmd/ksh93/sh/xec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index c61d3edcc..3578b67e8 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -2481,6 +2481,11 @@ int sh_exec(register const Shnode_t *t, int flags) errormsg(SH_DICT,ERROR_exit(1),e_ident,fname); UNREACHABLE(); } + if(shp->st.real_fun) + { + error(ERROR_exit(3),"namespaces cannot be defined in a ksh function scope"); + UNREACHABLE(); + } sfputc(stkp,'.'); sfputr(stkp,fname,0); np = nv_open(stkptr(stkp,offset),shp->var_tree,flags);