Skip to content

Commit

Permalink
Reset sh.arithrecursion in sh_exit() instead (re: d50d3d7)
Browse files Browse the repository at this point in the history
Since the arithmetic recursion level only becomes incorrect when
an error interrupts the arithmetic subsystem, and all such error
messages call sh_exit(), it should be good enough to reset it
there, so we don't need to do that for nearly every sh_exec() run.
  • Loading branch information
McDutchie committed Nov 25, 2021
1 parent 802e8db commit c9d7310
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions src/cmd/ksh93/sh/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ void sh_exit(register int xno)
sfclrlock(sfstdin);
if(!pp)
sh_done(shp,sig);
shp->arithrecursion = 0;
shp->prefix = 0;
#if SHOPT_TYPEDEF
shp->mktype = 0;
Expand Down
4 changes: 0 additions & 4 deletions src/cmd/ksh93/sh/xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,6 @@ int sh_exec(register const Shnode_t *t, int flags)
error_info.line = t->com.comline-shp->st.firstline;
com = sh_argbuild(shp,&argn,&(t->com),OPTIMIZE);
echeck = 1;
shp->arithrecursion = 0;
if(t->tre.tretyp&COMSCAN)
{
argp = t->com.comarg;
Expand Down Expand Up @@ -1890,7 +1889,6 @@ int sh_exec(register const Shnode_t *t, int flags)

case TPAR:
echeck = 1;
shp->arithrecursion = 0;
flags &= ~OPTIMIZE_FLAG;
if(!shp->subshell && !shp->st.trapcom[0] && !shp->st.trap[SH_ERRTRAP] && (flags&sh_state(SH_NOFORK)))
{
Expand Down Expand Up @@ -1960,7 +1958,6 @@ int sh_exec(register const Shnode_t *t, int flags)
int *exitval=0,*saveexitval = job.exitval;
pid_t savepgid = job.curpgid;
echeck = 1;
shp->arithrecursion = 0;
job.exitval = 0;
job.curjobid = 0;
if(shp->subshell)
Expand Down Expand Up @@ -2638,7 +2635,6 @@ int sh_exec(register const Shnode_t *t, int flags)
skipexitset++;
error_info.line = t->tst.tstline-shp->st.firstline;
echeck = 1;
shp->arithrecursion = 0;
if((type&TPAREN)==TPAREN)
{
sh_exec(t->lst.lstlef,OPTIMIZE);
Expand Down

0 comments on commit c9d7310

Please sign in to comment.