nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone

Blame SOURCES/bash-4.2-ifs-in-temp-env.patch

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