From: Robert Klemme Date: 2009-08-13T01:17:25+09:00 Subject: Re: Windows ENV object being corrupted 2009/8/12 Herman Schultz : > Robert Klemme wrote: >> 2009/8/11 Herman Schultz : >>> now, but I still can't wrap my head around why size plays a factor. >> I cannot either but this is due to the fact that I am missing >> information in your original posting.  For example, what is the format >> of the "batch file" are you reading?  What does variable "environment" >> contain? > > What I do is write the output from 'set' on windows to a ruby string > like this: > > environment = `call setEnvironment.bat;set` > > setEnvironment.bat is just a bunch of environment sets > > i.e.: SET LINK_PLATFORM=windows_32 > > The environment variables that were giving me trouble come from the > system > Ones like: > ALLUSERSPROFILE=C:\Documents and Settings\All Users > > So I get the sense that spaces are the issue, I believe that quoting > variables with spaces would probably solve the issue but I haven't tried > it yet. And what is your aim, i.e. what do you want to achieve? If you want to set environment variables for your Ruby script, you could easily do this instead: File.foreach "setEnvironment.bat" do |line| if /^\s*([^\s=]+)\s*=\s*(.*)$/ =~ line ENV[$1] = $2 end end and be done. Your approach looks suspiciously complicated to me. Of course I may be missing something... Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/