Blame SOURCES/ksh-20120801-fd2lost.patch

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