Blame SOURCES/ksh-20120801-fd2lost.patch

f38fd1
diff -up ksh-20120801/src/cmd/ksh93/sh/macro.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/macro.c
f38fd1
--- ksh-20120801/src/cmd/ksh93/sh/macro.c.fd2lost	2014-01-22 16:23:21.211658984 +0100
f38fd1
+++ ksh-20120801/src/cmd/ksh93/sh/macro.c	2014-01-22 16:23:21.243658703 +0100
f38fd1
@@ -391,7 +391,7 @@ void sh_machere(Shell_t *shp,Sfio_t *inf
f38fd1
 				break;
f38fd1
 			    }
f38fd1
 			    case S_PAR:
f38fd1
-				comsubst(mp,(Shnode_t*)0,1);
f38fd1
+				comsubst(mp,(Shnode_t*)0,3);
f38fd1
 				break;
f38fd1
 			    case S_EOF:
f38fd1
 				if((c=fcfill()) > 0)
f38fd1
@@ -1165,7 +1165,7 @@ retry1:
f38fd1
 	    case S_PAR:
f38fd1
 		if(type)
f38fd1
 			goto nosub;
f38fd1
-		comsubst(mp,(Shnode_t*)0,1);
f38fd1
+		comsubst(mp,(Shnode_t*)0,3);
f38fd1
 		return(1);
f38fd1
 	    case S_DIG:
f38fd1
 		var = 0;
f38fd1
diff -up ksh-20120801/src/cmd/ksh93/sh/subshell.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/subshell.c
f38fd1
--- ksh-20120801/src/cmd/ksh93/sh/subshell.c.fd2lost	2014-01-22 16:23:21.222658887 +0100
f38fd1
+++ ksh-20120801/src/cmd/ksh93/sh/subshell.c	2014-01-22 16:23:21.243658703 +0100
f38fd1
@@ -122,7 +122,8 @@ void	sh_subtmpfile(Shell_t *shp)
f38fd1
 		else if(errno!=EBADF)
f38fd1
 			errormsg(SH_DICT,ERROR_system(1),e_toomany);
f38fd1
 		/* popping a discipline forces a /tmp file create */
f38fd1
-		sfdisc(sfstdout,SF_POPDISC);
f38fd1
+		if(shp->comsub != 1)
f38fd1
+			sfdisc(sfstdout,SF_POPDISC);
f38fd1
 		if((fd=sffileno(sfstdout))<0)
f38fd1
 		{
f38fd1
 			/* unable to create the /tmp file so use a pipe */
f38fd1
@@ -635,6 +636,13 @@ Sfio_t *sh_subshell(Shell_t *shp,Shnode_
f38fd1
 		}
f38fd1
 		else
f38fd1
 		{
f38fd1
+			if(comsub!=1 && shp->spid)
f38fd1
+			{
f38fd1
+				job_wait(shp->spid);
f38fd1
+				if(shp->pipepid==shp->spid)
f38fd1
+					shp->spid = 0;
f38fd1
+				shp->pipepid = 0;
f38fd1
+			}
f38fd1
 			/* move tmp file to iop and restore sfstdout */
f38fd1
 			iop = sfswap(sfstdout,NIL(Sfio_t*));
f38fd1
 			if(!iop)
f38fd1
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.fd2lost ksh-20120801/src/cmd/ksh93/sh/xec.c
f38fd1
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.fd2lost	2014-01-22 16:23:21.237658756 +0100
f38fd1
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c	2014-01-22 16:38:36.374666019 +0100
f38fd1
@@ -1756,6 +1756,8 @@ int sh_exec(register const Shnode_t *t,
f38fd1
 					nlock--;
f38fd1
 					job_unlock();
f38fd1
 				}
f38fd1
+				if(shp->subshell)
f38fd1
+					shp->spid = parent;
f38fd1
 				if(type&FPCL)
f38fd1
 					sh_close(shp->inpipe[0]);
f38fd1
 				if(type&(FCOOP|FAMP))
f38fd1
@@ -1771,7 +1773,11 @@ int sh_exec(register const Shnode_t *t,
f38fd1
 					if(shp->pipepid)
f38fd1
 						shp->pipepid = parent;
f38fd1
 					else
f38fd1
+					{
f38fd1
 						job_wait(parent);
f38fd1
+						if(parent==shp->spid)
f38fd1
+							shp->spid = 0;
f38fd1
+					}
f38fd1
 					if(shp->topfd > topfd)
f38fd1
 						sh_iorestore(shp,topfd,0);
f38fd1
 					if(usepipe && tsetio &&  subdup && unpipe)