diff --git a/NEWS b/NEWS index a18d893321b8..e4d97c321825 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Any uppercase BUG_* names are modernish shell bug IDs. 2020-07-23: +- Fixed an infinite loop that could occur when ksh is the system's /bin/sh. + - A command substitution that is run on the same line as a here-document will no longer cause a syntax error. diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 5b91a232b6fb..2ca5a3c72fb0 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -710,7 +710,7 @@ static char* get_lastarg(Namval_t* np, Namfun_t *fp) char *cp; int pid; if(sh_isstate(SH_INIT) && (cp=shp->lastarg) && *cp=='*' && (pid=strtol(cp+1,&cp,10)) && *cp=='*') - nv_putval(np,(pid==shp->gd->ppid?cp+1:0),0); + nv_putval(np,cp+1,0); return(shp->lastarg); } diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c index ebcfee9ff134..2670a280eebe 100644 --- a/src/cmd/ksh93/sh/main.c +++ b/src/cmd/ksh93/sh/main.c @@ -273,7 +273,7 @@ int sh_main(int ac, char *av[], Shinit_f userinit) * try to undo effect of solaris 2.5+ * change for argv for setuid scripts */ - if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (!(name = nv_getval(L_ARGNOD)) || !((type = sh_type(cp = name)) & SH_TYPE_SH))) + if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (name = nv_getval(L_ARGNOD)) && (!((type = sh_type(cp = name)) & SH_TYPE_SH))) { av[0] = (type & SH_TYPE_LOGIN) ? cp : path_basename(cp); /* exec to change $0 for ps */