Jeffrey Schwab <jeff / schwabcenter.com> wrote:
> Trans wrote:
>> Jeffrey Schwab wrote:
>>> Trans wrote:
>> 
>> Let ty this:
>> 
>>   def FileTest.root?(dir)
>>     pth = File.expand_path(dir)
>>     return true if pth == '/'
>>     return true if pth =~ /^(\w:)?\/$/
>>     false
>>   end
>> 
>> The == line should give a slight speed boost to unix systems.
> 
> Looks good.
> 
> def FileTest.root?(dir)
>     pth = File.expand_path(dir)
>     return true if pth == '/'
>     return true if pth =~ /^(\w:)?\/$/
>     false
> end
> 
> 
> file = ARGV.shift
> 
> Dir.chdir('..') until File.executable?(file) or FileTest.root?(Dir.getwd)
> 
> puts Dir.getwd.gsub(/\/$/, '') + '/' + file if File.executable?(file)

Why not use this code to redefine Pathname.root?

--Ken

-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/