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:
parent
7439e3dffe
commit
72fe631b2f
1 changed files with 15 additions and 28 deletions
|
@ -782,24 +782,19 @@ static int setall(char **argv,register int flag,Dt_t *troot,struct tdata *tp
|
|||
if(!comvar && !iarray)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Create local scope for virtual 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
|
||||
* cloned, as moving them will remove the discipline function.
|
||||
*/
|
||||
np=sh_assignok(np,2);
|
||||
}
|
||||
else
|
||||
np=sh_assignok(np,0);
|
||||
}
|
||||
|
||||
if(troot==shp->var_tree)
|
||||
{
|
||||
if(shp->subshell)
|
||||
{
|
||||
/*
|
||||
* Create local scope for virtual subshell. Variables with discipline functions
|
||||
* (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);
|
||||
else
|
||||
np=sh_assignok(np,0);
|
||||
}
|
||||
if(iarray)
|
||||
{
|
||||
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);
|
||||
UNREACHABLE();
|
||||
}
|
||||
#if SHOPT_BSH
|
||||
if(flag&NV_EXPORT)
|
||||
nv_offattr(np,NV_IMPORT);
|
||||
#endif /* SHOPT_BSH */
|
||||
newflag = curflag;
|
||||
if(flag&~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;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(shp->subshell)
|
||||
{
|
||||
/*
|
||||
* Create local scope for virtual subshell. Variables with discipline functions
|
||||
* (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))
|
||||
{
|
||||
/*
|
||||
* Variables with internal trap/discipline functions (LC_*, LINENO, etc.) need to be
|
||||
* cloned, as moving them will remove the discipline function.
|
||||
*/
|
||||
np=sh_assignok(np,2);
|
||||
}
|
||||
else
|
||||
np=sh_assignok(np,0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
|
Loading…
Reference in a new issue