1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

typeset: only run sh_assignok() for variables (re: a2f13c19)

src/cmd/ksh93/bltins/typeset.c:
- setall(): Only run sh_assignok() if troot points to the variable
  tree. For instance, it's pointless to run it for an alias.
- Remove vestigial SHOPT_BSH code. The ast-open-history repo shows
  that earlier SHOPT_BSH code was removed on 2008-06-02 and
  2005-05-22. This may have been experimental code for increased
  compatibility with the ancient Bourne shell. There was never any
  documentation.
This commit is contained in:
Martijn Dekker 2021-05-01 00:43:12 +01:00
parent 7439e3dffe
commit 72fe631b2f

View file

@ -782,24 +782,19 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
if(!comvar && !iarray) if(!comvar && !iarray)
continue; continue;
} }
if(troot==shp->var_tree)
/* Create local scope for virtual subshell */ {
if(shp->subshell) if(shp->subshell)
{
if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
{ {
/* /*
* Variables with internal trap/discipline functions (LC_*, LINENO, etc.) need to be * Create local scope for virtual subshell. Variables with discipline functions
* cloned, as moving them will remove the discipline function. * (LC_*, LINENO, etc.) need to be cloned, as moving them will remove the discipline.
*/ */
if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
np=sh_assignok(np,2); np=sh_assignok(np,2);
}
else else
np=sh_assignok(np,0); np=sh_assignok(np,0);
} }
if(troot==shp->var_tree)
{
if(iarray) if(iarray)
{ {
if(tp->tname) if(tp->tname)
@ -884,10 +879,6 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
errormsg(SH_DICT,ERROR_exit(1),e_badexport,name); errormsg(SH_DICT,ERROR_exit(1),e_badexport,name);
UNREACHABLE(); UNREACHABLE();
} }
#if SHOPT_BSH
if(flag&NV_EXPORT)
nv_offattr(np,NV_IMPORT);
#endif /* SHOPT_BSH */
newflag = curflag; newflag = curflag;
if(flag&~NV_NOCHANGE) if(flag&~NV_NOCHANGE)
newflag &= NV_NOCHANGE; newflag &= NV_NOCHANGE;
@ -1355,22 +1346,18 @@ static int unall(int argc, char **argv, register Dt_t *troot, Shell_t* shp)
r=1; r=1;
continue; continue;
} }
if(shp->subshell) if(shp->subshell)
{
if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
{ {
/* /*
* Variables with internal trap/discipline functions (LC_*, LINENO, etc.) need to be * Create local scope for virtual subshell. Variables with discipline functions
* cloned, as moving them will remove the discipline function. * (LC_*, LINENO, etc.) need to be cloned, as moving them will remove the discipline.
*/ */
if(!nv_isattr(np,NV_NODISC|NV_ARRAY) && !nv_isvtree(np))
np=sh_assignok(np,2); np=sh_assignok(np,2);
}
else else
np=sh_assignok(np,0); np=sh_assignok(np,0);
} }
} }
/* /*
* When aliases are removed from the tree, the NV_NOFREE attribute must be used for * When aliases are removed from the tree, the NV_NOFREE attribute must be used for
* preset aliases since those are given the NV_NOFREE attribute. _nv_unset discards * preset aliases since those are given the NV_NOFREE attribute. _nv_unset discards