From: matz@... (Yukihiro Matsumoto) Date: 2001-03-12T08:01:16+09:00 Subject: [ruby-talk:12433] Re: RCR: Block form of Dir.chdir Hi, In message "[ruby-talk:12400] Re: RCR: Block form of Dir.chdir" on 01/03/11, YANAGAWA Kazuhisa writes: |In message |matju@sympatico.ca writes: | |> > Dir.chdir(new_dir) { |> > # work in new_dir... |> > } |> |> Sounds good to me. If File.open can, why not this one. | |``Because chdir changes context of a program'' ....I heard such. That |is, if one thread execute chdir, a working directory of other threads |also changed. This behavior can break an assumption on programming. That's what I said for 2 previous almost identical requests. In this sense, Guy Decoux did successfully read my mind again in [ruby-talk:12406]. |I personally think, we can alter the implementer's mind when more |complaints are arised :-) Yes. See Luke 18:2-5, if interested. I happen to find that even though I avoid block form of Dir.chdir, the following code is thread unsafe anyway. prev_dir = Dir.pwd Dir.chdir(new_dir) # work in new_dir... Dir.chdir(prev_dir) But I'm not going to make current directory thread independent. matz.