I agree with the reflective bit; Tom and I discussed this yesterday as
an ugly but warranted solution for 1.5ers who have access to the new
getenv stuff.
I also agree that system property namespace and ENV namespace should
be kept separate.
Tom's reply covered the rest of our discussion.
- Charlie
On 2/4/06, David Corbin <[EMAIL PROTECTED]> wrote:
> On Thursday 02 February 2006 05:36 pm, Tim Azzopardi wrote:
> > While testing the AntBuilder stuff, I found that ENV['RUBY_HOME'] is nil in
> > jruby but works in cruby. (There is only one environment variable that
> > works in jruby which is HOME because of a specific bit of code.)
> >
> > I had a go at fixing this initially using System.getenv() which returned a
> > hashmap of all the envonment variables. This was great until I realized it
> > was a Java5 feature.
> >
> > Having googled around a bit, I see that everyone has the same problem and
> > that pre java5 you need to drop out to the OS with
> > Runtime.getRuntime().exec("env"|"set") and parse the output.
> >
> > So I am happy to give this Runtime.exec("env"|"set") technique a go, if one
> > of you core jruby guys thinks its the right direction to go in.
> > ___________Is_the_right_direction___________? If not, I'll just drop it.
> >
>
> I think it's a reasonable direction, but I encourage you to reflectively call
> System.getEnv if you ARE on Java5. That is, have two ENV "loaders", and
> choose which one based on Java version.
>
> > If it is the right direction to go in, then I see a couple of basic ways to
> > implement:
> >
> > (a) from scratch, copy and or get inspiration from what look like many
> > "public domain" Runtime.exec solutions such as
> > http://www.rgagnon.com/javadetails/java-0150.html
> >
> > (b) Put ant.jar on the jruby classpath and call org.apache....Execute
> > getProcEnvironment() (which is a comprehensive Runtime..exec solution too).
> >
> > (c) Get inspiration from org.apache...Execute. (Presumably can't be copied
> > to jruby because of ASL2 license? Sigh...
> >
>
> Definately (a). Also, you should be sure to do this only once, and cache the
> results. And watch out for synchronization issues.
>
> > Aside number 1:
> > I can see that there is potential conflict/confusion between the
> > linux:env/windows:set namespace and the java System.getProperty()
> > namespace. Maybe the two namespaces can simply be combined in the ruby ENV
> > hash? Maybe a seperate jrurby specific global is required for the java
> > System.getProperty() namespace: ENV_JAVA or ENV_JRUBY or something.
>
> The two spaces should remain seperate entirely, if possible.
>
> > Aside number 2:
> > I wasn't intending to do anything about either of these comments in the
> > code related to the ENV global :
> > // TODO: ENV Not really a RubyHash (but close)
> > // TODO: ENV Should not copy system props, but should reference them
> > instead This seems like a seperate issue.
>
> Well, the second one will "go away", I think, won't it?
>
> > And finally, sorry if this an annoying low priority distraction from the
> > hard core stuff going on at the moment.
>
> It all needs to be done...
>
> >
> > Cheers all
> > Tim
> >
> >
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> > _______________________________________________
> > Jruby-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jruby-devel
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Jruby-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jruby-devel
>
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Jruby-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jruby-devel