From: Josh Huber Date: 2002-07-02T10:05:22+09:00 Subject: Re: Question: ruby vs. ksh Philip Mak writes: > On Tue, Jul 02, 2002 at 09:10:35AM +0900, Tim Hammerquist wrote: >> # 2) >> >> 'foo/bar'.split('/').each do |dir| >> Dir::mkdir(dir) >> end > > Isn't that going to do this: > > mkdir foo > mkdir bar > > instead of this: > > mkdir foo > mkdir foo/bar Yep, how about: tmp = "" 'foo/bar/baz'.split('/').each do |subdir| tmp << subdir + "/" Dir::mkdir(tmp) end But, yeah...using mkpath is probably the way to go, since it probably handles much more error cases. -- Josh Huber