Blob Blame Raw
diff -up ksh-20140415/src/cmd/ksh93/sh/subshell.c.hokaido ksh-20140415/src/cmd/ksh93/sh/subshell.c
diff -up ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido ksh-20140415/src/cmd/ksh93/sh/xec.c
--- ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido	2014-03-17 22:13:55.000000000 +0100
+++ ksh-20140415/src/cmd/ksh93/sh/xec.c	2014-05-20 18:23:49.712532290 +0200
@@ -1630,12 +1630,20 @@ tryagain:
 #endif /* SHOPT_COSHELL */
 			if(shp->subshell)
 			{
+				int comsubsave = shp->comsub;
+				if(comsubsave==1)
+					shp->comsub = 2;
 				sh_subtmpfile(shp);
+				shp->comsub = comsubsave;
+				if(shp->comsub==1 && !(shp->fdstatus[1]&IONOSEEK))
+					unpipe = iousepipe(shp);
+
 				if((type&(FAMP|TFORK))==(FAMP|TFORK))
 				{
 					if(shp->comsub && !(shp->fdstatus[1]&IONOSEEK))
 					{
-						unpipe = iousepipe(shp);
+						if (!unpipe)
+							unpipe = iousepipe(shp);
 						sh_subfork();
 					}
 				}