Hi,

When gnulib's putenv module is included, it will be used on mingw.
Variables put in the environment using gnulib's putenv do not make
it past exec.

You can easily verify this by applying the patch below and creating
a test for unsetenv and remove-file and running test-unsetenv.exe

I'm also attaching mingw-putenv.c which makes it easy to see that
the putenv that mingw provides does not suffer from this problem.

I haven't investigated whether it's environment or putenv which is
broken.

Greetings,
Jan.

-- 
Jan Nieuwenhuizen <[email protected]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ®  http://AvatarAcademy.nl  
diff --git a/tests/test-unsetenv.c b/tests/test-unsetenv.c
index 9c9443b..f8336ba 100644
--- a/tests/test-unsetenv.c
+++ b/tests/test-unsetenv.c
@@ -57,5 +57,23 @@ main (void)
   ASSERT (errno == EINVAL);
 #endif
 
+  /* Check that putenv survives exec */
+#define WORKS "works"
+  putenv ("gnulib_putenv=" WORKS);
+#define FILE "file"
+#ifndef __MINGW32__
+#define ECHO "/bin/bash -c 'echo "
+#else /* __MINGW32__ */
+#define ECHO "c:/cygwin/bin/bash.exe -c 'echo "
+#endif /* __MINGW32__ */
+  system (ECHO " -n .$PATH. '");
+  system (ECHO " -n .$gnulib_putenv. '");
+  system (ECHO " -n .$gnulib_putenv. >" FILE " '");
+  size_t size;
+  char *s = read_file (FILE, &size);
+  ASSERT (strcmp (s, "." WORKS ".") == 0);
+  free (s);
+  remove (FILE);
+
   return 0;
 }
#include <stdlib.h>
#include <string.h>

int
main ()
{
  /* Check that putenv survives exec */
#define WORKS "works"
  putenv ("gnulib_putenv=" WORKS);
#define FILE "file"
#ifndef __MINGW32__
#define ECHO "/bin/bash -c 'echo "
#else /* __MINGW32__ */
#define ECHO "c:/cygwin/bin/bash.exe -c 'echo "
#endif /* __MINGW32__ */
  system (ECHO " -n .$PATH. '");
  system (ECHO " -n .$gnulib_putenv. '");
  system (ECHO " -n .$gnulib_putenv. >" FILE " '");

  return 0;
}

Reply via email to