From: Fabian Marin on 27 Jul 2010 22:03 hope I did not misunderstand the question, but would this work?? %x{which $0} It seems too easy to work so I probably missed something :P -- Posted via http://www.ruby-forum.com/.
From: Hassan Schroeder on 27 Jul 2010 22:20 On Tue, Jul 27, 2010 at 7:03 PM, Fabian Marin <fmg134s(a)yahoo.com> wrote: > hope I did not misunderstand the question, but would this work?? > > %x{which $0} > > It seems too easy to work so I probably missed something :P Thanks, but $ irb >> %x{which $0} => "/bin/sh\n" isn't what I was looking for :-) -- Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com twitter: @hassan
From: Edward Middleton on 27 Jul 2010 23:22 On 07/28/2010 11:20 AM, Hassan Schroeder wrote: > On Tue, Jul 27, 2010 at 7:03 PM, Fabian Marin <fmg134s(a)yahoo.com> wrote: >> hope I did not misunderstand the question, but would this work?? >> >> %x{which $0} >> >> It seems too easy to work so I probably missed something :P > > Thanks, but > $ irb >>> %x{which $0} > => "/bin/sh\n" > > isn't what I was looking for :-) Thats because the $0 is being evaluated by the shell not ruby. What you actually want is %x{which #{$0}} which will give "which irb" to the shell. If the PATH environment is the same this should give you the full path. Edward
From: Fabian Marin on 28 Jul 2010 00:22 Edward Middleton wrote: > On 07/28/2010 11:20 AM, Hassan Schroeder wrote: >> => "/bin/sh\n" >> >> isn't what I was looking for :-) > > Thats because the $0 is being evaluated by the shell not ruby. What you > actually want is %x{which #{$0}} which will give "which irb" to the > shell. If the PATH environment is the same this should give you the > full path. > > Edward Yeah I missed that. I could not execute/test the code I suggested because I'm using Win XP right now, sigh... Edward, you're right. Once $0 is evaluated by Ruby that should work in a Unix environment. -- Posted via http://www.ruby-forum.com/.
From: Caleb Clausen on 28 Jul 2010 02:41 On 7/27/10, Fabian Marin <fmg134s(a)yahoo.com> wrote: > Edward, you're right. Once $0 is evaluated by Ruby that should work in > a Unix environment. But watch: $ ruby -e 'p $0' "-e" That doesn't seem to helpful. Hassan seemed to want the path to the ruby interpreter, not the path to the ruby script it's executing. Hassan, what is you objection to using rbconfig.rb as Joel suggests? AFAIK, that's the best (only real) solution to this particular problem.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: In Ruby 1.9 Test::Unit::TestCase parse ARGV differently Next: Chat client |