When I have an executable ruby script foo
starting with a shebang
foo
#!/usr/bin/env ruby
and call that ruby script from within a bash script bar
as executable (i.e., not calling ruby foo
, but directly foo
), how can I get the full path of bar
from within the ruby script foo
?
Edit
If this is not possible, then is it possible if I have a bash script baz
in between so that:
bar
(bash) calls baz
(bash) which calls foo
(ruby)
where bar
calls baz
without any explicit argument and baz
figures out the path of its caller bar
, and passes that as an argument when calling foo
?
For my purpose, it is okay whether or not foo
needs to receive the path information as an argument as long as the original bash script bar
does not need to pass that explicitly.