matz / zetabits.com (Yukihiro Matsumoto) writes:

> |I think there's a simpler solution to the original problem: add the
> |directory from which the main Ruby program was run to the search path
> |if SAFE is 0. So, if I say
> |
> |   ruby ../../demo/fred.rb
> |
> |then '../../demo' will be prepended to $:
> 
> This has been proposed several times (in Japanese list), but I
> couldn't find the portable and reliable way to get the base path of
> the executable file on UNIX flavored OS.  Can you?

I guess there are two cases:

   1. When the program is run using:

             ruby  <path_to_rb>  <options>

      Then you know the path, and all's well

   2. When the program's run using a shebang line, then you may or may 
      not get the path to the .rb file included. On Linux, this
      doesn't seem to be a problem. What's the status with other
      Unices?


Dave