Forum: Ruby tar2rubyscript: getting the path of the original executable

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.
5282a59bd311c99bf650bddfbc307f6a?d=identicon&s=25 Patrick Gundlach (pgundlach)
on 2007-01-23 14:52
Hi,

I try using tar2rubyscript and I need to get the path to the original
executable. oldlocation doesn't seem to help because it referes to the
original working directory. Any idea?

Patrick
6b0967f63d03e99b6c07a3f5ed224c77?d=identicon&s=25 Erik Veenstra (Guest)
on 2007-01-23 18:03
(Received via mailing list)
----------------------------------------------------------------

 $ cat application/init.rb
 p $0
 p __FILE__

 $ ruby tar2rubyscript.rb application/
 Creating archive...
 Creating application.rb ...

 $ ruby application.rb
 "...../Temp/tar2rubyscript.d.2900.1/application/init.rb"
 "...../Temp/tar2rubyscript.d.2900.1/application/init.rb"
5282a59bd311c99bf650bddfbc307f6a?d=identicon&s=25 Patrick Gundlach (pgundlach)
on 2007-01-23 18:16
Erik Veenstra wrote:
> ----------------------------------------------------------------
>
>  $ cat application/init.rb
>  p $0
>  p __FILE__


Thanks Erik, but obviously I wasn't clear. I need the path to the old
.rb file, the one that is distributed and contains the tar file, not the
one in the temporary directory.

With __FILE__ and $0 I get the new location, with oldlocation I only get
the last PWD and not the location of the tar/rb file.

Patrick
6b0967f63d03e99b6c07a3f5ed224c77?d=identicon&s=25 Erik Veenstra (Guest)
on 2007-01-23 18:55
(Received via mailing list)
Sorry, I misunderstood your question...

Currently, it's not possible to determine the path to the RBA.

Mmm...

gegroet,
Erik V. - http://www.erikveen.dds.nl/
5282a59bd311c99bf650bddfbc307f6a?d=identicon&s=25 Patrick Gundlach (pgundlach)
on 2007-01-26 10:29
Erik Veenstra wrote:
> Sorry, I misunderstood your question...
>
> Currently, it's not possible to determine the path to the RBA.
>
> Mmm...

Then I have two suggestions for tar2rubyscript:

1) create an environment variable that points to the RBA
2) make the filename 'init.rb' configurable

Thanks in advance,

Patrick
This topic is locked and can not be replied to.