On 3/22/10 6:21 PM, Mike Frysinger wrote: > ok, the trouble is that we take the code, save it via `set`, and then restore > it.
OK, that was the missing piece. Not really anything to do with the redirection code per se. > the assumption is that what bash outputs is equivalent to the original > code. bash-4 though does not provide equivalent code. Yeah, that's pretty weird. An artifact of the changes to print here documents correctly in the presence of operators like |, ||, and &&. > so here is the reduced test case: > $ cat test.sh > foo() { > rm -f a b c > for f in a b c; do > cat <<-EOF >> ${f} > file > EOF > done > grep . a b c > } > > $ . ./test.sh > $ foo > a:file > b:file > c:file The attached patch fixes it for me. Let me know. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.1-patched/print_cmd.c 2009-09-16 15:32:26.000000000 -0400 --- print_cmd.c 2010-03-22 21:15:30.000000000 -0400 *************** *** 114,117 **** --- 114,123 ---- #define CHECK_XTRACE_FP xtrace_fp = (xtrace_fp ? xtrace_fp : stderr) + #define PRINT_DEFERRED_HEREDOCS(x) \ + do { \ + if (deferred_heredocs) \ + print_deferred_heredocs (x); \ + } while (0) + /* Non-zero means the stuff being printed is inside of a function def. */ static int inside_function_def; *************** *** 561,571 **** { print_for_command_head (for_command); - cprintf (";"); newline ("do\n"); indentation += indentation_amount; make_command_string_internal (for_command->action); semicolon (); indentation -= indentation_amount; newline ("done"); } --- 566,578 ---- { print_for_command_head (for_command); cprintf (";"); newline ("do\n"); + indentation += indentation_amount; make_command_string_internal (for_command->action); + PRINT_DEFERRED_HEREDOCS (""); semicolon (); indentation -= indentation_amount; + newline ("done"); }