Then $0 would need to be absolute too.
snoopy vars are on the way out - that's what __PROGRAM__ is (in theory)...
So the question is, would, could switching the default $0 setting and
__FILE__ to absolute paths break existing programs?
perhaps it should then be:
$SCRIPT_FILE => absolute path of script file
$PROGRAM_NAME => absolute path of called program
$RUBY => absolute path of ruby interp running called program
$BASE_DIR => absolute directory of file (can use for relative
or (__VAR__ - take your pick)
and this breaks no current code (probably).
now that i think about it, if you are putting an RCR together it might make
sense to create a namespace for the notion of 'stuff specific to this instance
of ruby' and put all this stuff in there. something like
require 'rbconfig'
require 'pathname'
module Runtime
SCRIPT_FILE = Pathname.new(__FILE__).realpath.to_s
PROGRAM_NAME = Pathname.new($0).realpath.to_s
RUBY = File.join Config::CONFIG['bindir'], Config::CONFIG['RUBY_INSTALL_NAME']
BASE_DIR = File.dirname SCRIPT_FILE
end
or perhaps implement the namespace as in
ENV['RUBY_SCRIPT_FILE'] = Pathname.new(__FILE__).realpath.to_s
who knows...
all i'm saying is, if a namespace was inforced we could put all sorts of
useful stuff in there w/o breaking old code.
Are there Windows considerations that could cause problems? Cygwin?
MinGW?
I'm considering writing up an RCR, but before I put Matz and myself
through all that, I want to make sure we're not wasting time.
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL ::
http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================