$0 == __FILE__ idiom for Unix only?

I have been using the Ruby idiom ‘if $0 == FILE … end’ for
ages on Linux and now that I have to use some of my scripts on WIndows
it looks like this test doesn’t work?

Is this supposed to work on Unix/Linux only or on all platforms??

Thanks

LJ

I don’t have acess to a windows system, but it works on windows
dependening upon how program is called. That is, through

ruby myrubyprog.rb

or through the autolaunching of .rb files…IIRC.

···

On Fri, Sep 06, 2002 at 02:15:17AM +0900, Laurent Julliard wrote:

I have been using the Ruby idiom ‘if $0 == FILE … end’ for
ages on Linux and now that I have to use some of my scripts on WIndows
it looks like this test doesn’t work?

Is this supposed to work on Unix/Linux only or on all platforms??


Jim Freeze

Programming Ruby
def initialize; fun; end
A language with class

if FILE == $0

end

or

if $0 == FILE

end

both works on Windows.

hth,
alia

Laurent Julliard wrote:

···

I have been using the Ruby idiom ‘if $0 == FILE … end’ for
ages on Linux and now that I have to use some of my scripts on WIndows
it looks like this test doesn’t work?

Is this supposed to work on Unix/Linux only or on all platforms??

Thanks

LJ

I have been using the Ruby idiom ‘if $0 == FILE … end’ for
ages on Linux and now that I have to use some of my scripts on WIndows
it looks like this test doesn’t work?

Is this supposed to work on Unix/Linux only or on all platforms??

Works all the time for me on Windows…

chris