CodeSmith CodeSmith - 1 year ago 48
Ruby Question

How to find the full path that was used to run a Ruby script

I have a script ("foo") that gets installed as an executable command on the path. I can invoke

on the commandline to get the currently installed version.

But sometimes I like to run a development version by running

Is there a way that I can tell if
was invoked by calling
or if it was called using the full path?

Answer Source

You can access that value as $0 inside your script.