From: Glenn Jackman Date: 2009-08-11T02:00:17+09:00 Subject: Re: how to "source" a file? At 2009-08-07 06:53PM, "David Masover" wrote: > On Friday 07 August 2009 02:55:11 pm Glenn Jackman wrote: > > Since Ruby is not Bash, you have to parse the file: > > > > File.foreach("myenv") do |line| > > line.chomp.scan(/^export (.+?)=(.*)$/) do |name, val| > > ENV[name] = val > > end > > end > > > > p ENV['FOO'] # => "bar" > > That's pretty fragile -- it would severely limit what you can put in > the file. I don't understand this comment. How is it "severely limiting"? Granted, it won't properly parse export a=b c=d e=f foo bar and I didn't account for extra whitespace. The OP didn't specify any such requirements though. But it's not going to get tripped up by any line that doesn't match the pattern. It won't run off and execute any of the other commands in this bash file. I'm not personally offended by your comments, I'm curious to learn more. -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous