MonkeeSage <MonkeeSage / gmail.com> wrote:

> I know...I saw your first post. But that seems very direct to me. I
> think you meant immediate, i.e., without calling a method. There is no
> way to do that, that I know of anyway, but you can always do it
> yourself (you could even make a file just for that):
> 
> ### direct.rb ###
> $base = File.basename($0)
> 
> ### somethingelse.rb ###
> require 'direct'
> puts $base

in ruby what's the meaning of "$" before base ?
a way to get it as global var ?

> I do something similar to find the real path of a script:
> 
> ### realpath.rb ###
> # This basically does the same thing as:
> #   require 'pathname'
> #   File.dirname(Pathname.new($0).realpath)
> $realpath = File.expand_path($0)
> if File.symlink?($realpath)
>   $realpath = File.readlink($realpath)
> end
> $realpath = File.dirname($realpath)
> 
> ### somethingelse.rb ###
> require 'realpath'
> puts $realpath


Right, nice idae, i do have a folder "rb" in my HOME/bin where i put
some small ruby scripts like that and some ruby object extension such as
string.

quit frankly i was wrong i've believe the behaviour of shell scripts is
different then, i've made a riny test in zsh (my prefered shell) :

#!/usr/bin/env zsh
echo $0
exit 0

and i get, as for ruby :

~%> zsh echo_dollard_9.zsh
/Users/yvon/work/zsh/echo_dollard_0.zsh

)))))
-- 
une bue