Forum: Ruby how to implement a UNIX 'export' in Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5c71423873bdfb81bdcc8f56dc2df793?d=identicon&s=25 Thomas Luedeke (tpl)
on 2013-06-04 20:30
I've been googling and getting nowhere on this, and I find it an
extremely confusing topic - the use of environment variables in Ruby,
compared to UNIX.

I've converted some obsolescent UNIX scripts (used to perform
verification and validation of computer codes) into Ruby.  I'm now
running into the problem that I need to set an environment variable on
the g95 compiler to get the test cases to run correctly.

So in the UNIX script, they use something like "export
G95_MINUS_ZERO=true".

How in the world do I implement something like this in Ruby?  Is it as
simple as:

ENV['G95_MINUS_ZERO'] = "true"
Abdb670e1c130f96f947a94d03c02efa?d=identicon&s=25 Eric Christopherson (echristopherson)
on 2013-06-04 21:47
(Received via mailing list)
On Tue, Jun 4, 2013 at 1:30 PM, Thomas Luedeke <lists@ruby-forum.com>
wrote:

> G95_MINUS_ZERO=true".
>
> How in the world do I implement something like this in Ruby?  Is it as
> simple as:
>
> ENV['G95_MINUS_ZERO'] = "true"


Have you tried it? I don't have g95, but a similar test case worked for
me.
0e6ac58dab6125c1cd2e7ac645076b6f?d=identicon&s=25 Joel VanderWerf (Guest)
on 2013-06-04 21:56
(Received via mailing list)
On 06/04/2013 11:30 AM, Thomas Luedeke wrote:
> G95_MINUS_ZERO=true".
>
> How in the world do I implement something like this in Ruby?  Is it as
> simple as:
>
> ENV['G95_MINUS_ZERO'] = "true"

Yup.

$ ruby -ve 'ENV["foo"] = "bar"; system "echo $foo"'
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
bar
This topic is locked and can not be replied to.