From: Trans Date: 2006-08-14T23:50:12+09:00 Subject: Re: sh command that ascends dir tree for executable Jeffrey Schwab wrote: > Not quite, but it's a great idea! You might want to sit down for this one: > > C:\>ruby -rpathname -e 'puts Pathname.getwd' > C:/ > > C:\>ruby -rpathname -e 'puts Pathname.getwd.parent' > C:/.. > > Could you live with something like this, or are the regex/string > manipulation/punctuation just too ugly? > > file = ARGV.shift > > Dir.chdir('..') until File.executable?(file) or > Dir.getwd =~ /^(?:\w:)?[\/\.]*$/ > > puts Dir.getwd.gsub(/\/$/, '') + '/' + file if File.executable?(file) Guess I don't have much of choice. Pretty sad choice though. I can't beleive there's not a cleaner solution. T.