From: "Berger, Daniel" Date: 2007-10-02T01:50:29+09:00 Subject: Dir.chdir patch for MS Windows Hi, Dir.chdir without any arguments will usually raise an error on MS Windows because ENV['HOME'] is not typically set. This patch resorts to USERPROFILE on Windows instead of LOGDIR. It also updates the rdoc. If the goal is to emulate typical shell behavior, then Dir.chdir with no arguments on MS Windows should perform no action and simply return the current directory. If that's the case, the docs will need to be updated. Personally, I favor this patch instead. Regards, Dan C:\>diff -u dir.orig dir.c --- dir.orig Tue May 22 13:22:14 2007 +++ dir.c Mon Oct 01 10:42:28 2007 @@ -749,8 +749,9 @@ * Changes the current working directory of the process to the given * string. When called without an argument, changes the directory to * the value of the environment variable HOME, or - * LOGDIR. SystemCallError (probably - * Errno::ENOENT) if the target directory does not exist. + * LOGDIR (USERPROFILE on MS Windows). Raises a + * SystemCallError (probably Errno::ENOENT) if + * the target directory does not exist. * * If a block is given, it is passed the name of the new current * directory, and the block is executed with that as the current @@ -795,8 +796,13 @@ else { const char *dist = getenv("HOME"); if (!dist) { +#ifdef _WIN32 + dist = getenv("USERPROFILE"); + if (!dist) rb_raise(rb_eArgError, "HOME/USERPROFILE not set"); +#else dist = getenv("LOGDIR"); if (!dist) rb_raise(rb_eArgError, "HOME/LOGDIR not set"); +#endif } path = rb_str_new2(dist); } This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.