Forum: JRuby question about jruby command line call implementation

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.
1ed4bbef573bfc014d32356d53103ca2?d=identicon&s=25 Phil Swenson (philswenson)
on 2009-02-26 01:38
(Received via mailing list)
On the groovy list I was asking why one of my calls to the shell using
groovy's String.execute() method wasn't working.

I got this response:

"At least for question #1, you can't "cd" to a dir in Java, and Groovy
inherits from the same limitation."

Does JRuby have this limitation?

e.g.:  `cd /blah/bin;;./startup.sh`

If not, how did JRuby get around the "java doesn't let you cd to a
dir" limitation?  native?

thanks

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ea3084bf9444c7d0cd0c640ca0ac93b3?d=identicon&s=25 Logan Barnett (Guest)
on 2009-02-26 01:51
(Received via mailing list)
On Feb 25, 2009, at 5:37 PM, phil swenson wrote:

> e.g.:  `cd /blah/bin;;./startup.sh`
I would think this would work, but you can also do this:
puts Dir.pwd
require 'fileutils'
FileUtils.cd('foo') do
   puts Dir.pwd   #different from the first call. Anything that
piggybacks on pwd should work under this context
end

>
>
> If not, how did JRuby get around the "java doesn't let you cd to a
> dir" limitation?  native?

Maybe there's a system property that stores the PWD?


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
7a911e6eb94f7be3e6bd4623145df192?d=identicon&s=25 Matt Fletcher (Guest)
on 2009-03-02 15:17
(Received via mailing list)
Since you are running that command through backticks, JRuby will run
that
command for you using sh -c or cmd /c. So it isn't the same Java process
that is changing directories; it is a different process instead.
You can run into trouble with JRuby because it will sometimes try to
execute
new processes within the same VM instance; it takes a peek at the
command
you are running and if it looks like ruby or jruby it will run it in the
same process. This behavior has caught me offguard a few times. It can
be
disabled.
This topic is locked and can not be replied to.