--- bash-4.2/redir.c 2015-04-27 23:03:55.663182162 +0200 +++ bash-4.2/redir.c 2015-04-27 23:03:13.995181816 +0200 @@ -63,6 +63,7 @@ int expanding_redir; extern int posixly_correct; extern int last_command_exit_value; +extern int executing_builtin; extern REDIRECT *redirection_undo_list; extern REDIRECT *exec_redirection_undo_list; @@ -307,11 +308,23 @@ write_here_string (fd, redirectee) WORD_DESC *redirectee; { char *herestr; - int herelen, n, e; + int herelen, n, e, old; expanding_redir = 1; + /* Now that we've changed the variable search order to ignore the temp + environment, see if we need to change the cached IFS values. */ + sv_ifs ("IFS"); herestr = expand_string_to_string (redirectee->word, 0); expanding_redir = 0; + /* Now we need to change the variable search order back to include the temp + environment. We force the temp environment search by forcing + executing_builtin to 1. This is what makes `read' get the right values + for the IFS-related cached variables, for example. */ + old = executing_builtin; + executing_builtin = 1; + sv_ifs ("IFS"); + executing_builtin = old; + herelen = STRLEN (herestr); n = write (fd, herestr, herelen);