On Nov 18, 2013, at 11:08 PM, Robert Klemme <shortcutter / googlemail.com> =
wrote:

> On Tue, Nov 19, 2013 at 5:28 AM, Previn Lin <lists / ruby-forum.com> =
wrote:
>> I want to setup a tool, which set the env by source a csh file.
>>=20
>> Is there way to source csh env file in Ruby?
>>=20
>> For the attached test case, I wrote ruby as below, but seems don't =
work.
>>=20
>> #!/usr/bin/env ruby
>>=20
>> system "source test.csh"
>=20
> The shell cannot read a CSV file that way.  Even if using the output
> in Ruby would work that code breaks already in the shell.

Why CSV? The original poster asked about CSH (Unix C Shell) environment =
propagation to Ruby. I think what he wants is this:

`csh -c 'source test.csh; env'`.lines.each do |_line|
    ENV.store *_line.chomp.split('=3D', 2)
end

Then the following will work as expected:
puts "a =3D #{ENV['SYSTYPE']}"

>=20
>> puts "a =3D #{ENV['SYSTYPE']}"
>>=20
>> Your help will be very appreciated.
>=20
> Use http://ruby-doc.org/stdlib-1.9.3/libdoc/csv/rdoc/CSV.html to
> iterate records from CSV file and use ENV.[]=3D to set environment
> variables.
>=20
> Kind regards
>=20
> robert
>=20
> --=20
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/