462fb2
diff --git a/execute_cmd.c b/execute_cmd.c
462fb2
--- a/execute_cmd.c
462fb2
+++ b/execute_cmd.c
462fb2
@@ -536,6 +536,10 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
462fb2
   REDIRECT *my_undo_list, *exec_undo_list;
462fb2
   volatile int last_pid;
462fb2
   volatile int save_line_number;
462fb2
+#if defined (PROCESS_SUBSTITUTION)
462fb2
+  volatile int ofifo, nfifo, osize, saved_fifo;
462fb2
+  volatile char *ofifo_list = NULL;
462fb2
+#endif
462fb2
 
462fb2
 #if 0
462fb2
   if (command == 0 || breaking || continuing || read_but_dont_execute)
462fb2
@@ -681,6 +685,17 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
462fb2
   if (shell_control_structure (command->type) && command->redirects)
462fb2
     stdin_redir = stdin_redirects (command->redirects);
462fb2
 
462fb2
+#if defined (PROCESS_SUBSTITUTION)
462fb2
+  if (variable_context != 0)
462fb2
+    {
462fb2
+      ofifo = num_fifos ();
462fb2
+      ofifo_list = copy_fifo_list ((int*)&osize);
462fb2
+      saved_fifo = 1;
462fb2
+    }
462fb2
+  else
462fb2
+    saved_fifo = 0;
462fb2
+#endif
462fb2
+
462fb2
   /* Handle WHILE FOR CASE etc. with redirections.  (Also '&' input
462fb2
      redirection.)  */
462fb2
   if (do_redirections (command->redirects, RX_ACTIVE|RX_UNDOABLE) != 0)
462fb2
@@ -688,6 +703,9 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
462fb2
       cleanup_redirects (redirection_undo_list);
462fb2
       redirection_undo_list = (REDIRECT *)NULL;
462fb2
       dispose_exec_redirects ();
462fb2
+#if defined (PROCESS_SUBSTITUTION)
462fb2
+      free ((void*)ofifo_list);
462fb2
+#endif
462fb2
       return (last_command_exit_value = EXECUTION_FAILURE);
462fb2
     }
462fb2
 
462fb2
@@ -982,6 +1000,17 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
462fb2
   if (my_undo_list || exec_undo_list)
462fb2
     discard_unwind_frame ("loop_redirections");
462fb2
 
462fb2
+#if defined (PROCESS_SUBSTITUTION)
462fb2
+  if (saved_fifo)
462fb2
+    {
462fb2
+      nfifo = num_fifos ();
462fb2
+      if (nfifo > ofifo)
462fb2
+       close_new_fifos ((char*)ofifo_list, osize);
462fb2
+      free ((void*)ofifo_list);
462fb2
+    }
462fb2
+#endif
462fb2
+
462fb2
+
462fb2
   /* Invert the return value if we have to */
462fb2
   if (invert)
462fb2
     exec_result = (exec_result == EXECUTION_SUCCESS)