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