From: Ken Bloom Date: 2006-08-15T22:45:06+09:00 Subject: Re: sh command that ascends dir tree for executable Jeffrey Schwab 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/