Skip to content

Commit

Permalink
Fix ordering of if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnoKing committed Dec 17, 2024
1 parent 967a80a commit e429d71
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cmd/ksh93/sh/subshell.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,16 @@ Sfio_t *sh_subshell(Shnode_t *t, volatile int flags, int comsub)
}
sh.options = sp->options;
/* restore the present working directory */
if(sp->pwdfd > 0 && fchdir(sp->pwdfd) < 0)
if(sh.pwdfd != sp->pwdfd && sp->pwdfd > 0 && fchdir(sp->pwdfd) < 0)
{
sh_close(sp->pwdfd);
saveerrno = errno;
fatalerror = 2;
}
if(fatalerror != 2)
sh_pwdupdate(sp->pwdfd);
else if(sp->pwd && strcmp(sp->pwd,sh.pwd))
path_newdir(sh.pathlist);
if(fatalerror != 2)
sh_pwdupdate(sp->pwdfd);
if(sh.pwd)
free((void*)sh.pwd);
sh.pwd = sp->pwd;
Expand Down

0 comments on commit e429d71

Please sign in to comment.