From: Ken Bloom Date: 2006-08-14T14:00:11+09:00 Subject: Re: sh command that ascends dir tree for executable On Sun, 13 Aug 2006 23:36:51 +0000, Jeffrey Schwab wrote: > Trans wrote: >> Jeffrey Schwab wrote: >>> Trans wrote: >>>> Thanks Jeffrey and Ken. I was thinking maybe there was a util for this >>>> already but I suppose not. I wrote code like this: >>>> >>>> Dir.chdir('..') until File.exectuable?( file ) >>>> >>>> It does change the directory, but for my purposes that's okay. See any >>>> problems with that? Work with Windows okay? >>> It'll loop forever if the file doesn't exist. >> >> Dir.chdir('..') until File.exectuable?( file ) or Dir.pwd == '/' >> >> Will that work on Windows? If not what do I need to match? > > 'Fraid not. Windows filesystems don't allow mounting the way Unix > filesystems do, so you end up with multiple "root" directories whose > names include letters and colons. E.g., you probably know that the hard > drive of most PCs is called "C:\". > > Pathname.root? seemed promising, but it doesn't work properly on > Windows, either. Windows isn't a very good collection of operating > systems, and I think most Ruby developers are smart enough to avoid it. Does Pathname.getwd.parent==Pathname.getwd work on Windows? I didn't realize there was Pathname.root? for me to use it would probably have simplified things in my code a lot. --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/