diff --git a/NEWS b/NEWS index 92ce30a42..9868bedc7 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,9 @@ Any uppercase BUG_* names are modernish shell bug IDs. 3. The -c/--call, -n/--name and -s/--standard options matched all variable names provided by 'getconf -a', even if none were actual matches. +- The readonly attribute of ksh variables is no longer imported from + or exported to other ksh shell instances through the environment. + 2021-04-16: - Fixed a bug in emacs mode: after using tab completion to complete the name diff --git a/src/cmd/ksh93/COMPATIBILITY b/src/cmd/ksh93/COMPATIBILITY index 5d6f267b0..a4e1c7705 100644 --- a/src/cmd/ksh93/COMPATIBILITY +++ b/src/cmd/ksh93/COMPATIBILITY @@ -129,6 +129,9 @@ For more details, see the NEWS file and for complete details, see the git log. To invoke a possible external command at that path, you can still use a non-canonical path, e.g.: /opt//ast/bin/cat or /opt/ast/./bin/cat +24. The readonly attribute of ksh variables is no longer imported from + or exported to other ksh shell instances through the environment. + ____________________________________________________________________________ KSH-93 VS. KSH-88 diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 97ca10153..852a14394 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -1986,6 +1986,9 @@ static void env_import_attributes(Shell_t *shp, char *next) size--; } } + flag &= ~NV_RDONLY; /* refuse to import readonly attribute */ + if(!flag) + continue; nv_newattr(np,flag|NV_IMPORT|NV_EXPORT,size); } } diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c index b77e82ff3..9b571bd8a 100644 --- a/src/cmd/ksh93/sh/name.c +++ b/src/cmd/ksh93/sh/name.c @@ -2241,7 +2241,7 @@ char **sh_envgen(void) /* Export variable attributes into env var named by e_envmarker, unless POSIX mode is on */ cp = data.attval = strcopy(*data.argnam,e_envmarker); if(!sh_isoption(SH_POSIX)) - nv_scan(shp->var_tree, attstore,&data,0,(NV_RDONLY|NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER)); + nv_scan(shp->var_tree, attstore,&data,0,(NV_UTOL|NV_LTOU|NV_RJUST|NV_LJUST|NV_ZFILL|NV_INTEGER)); *data.attval = 0; if(cp!=data.attval) data.argnam++;