
Issue #20056 has been updated by jeremyevans0 (Jeremy Evans). Not passing an argument to the block in the Dir.fchdir or Dir#chdir case makes sense to me. A directory may not even know the path (e.g. `Dir.for_fd(dir_fd).chdir`), and yielding the file descriptor doesn't seem helpful (plus it isn't portable). Note that whether the block is passed an argument in the Dir#chdir case depends on the platform. If the platform supports fchdir, then no argument is passed, but if it does not support an argument, then the path is passed. This isn't optimal, ideally no argument should passed in any case. That will take a little refactoring. ---------------------------------------- Misc #20056: Dir#chdir inconsistency with Dir.chdir https://bugs.ruby-lang.org/issues/20056#change-105631 * Author: zverok (Victor Shepelev) * Status: Open * Priority: Normal * Assignee: jeremyevans0 (Jeremy Evans) ---------------------------------------- I am not sure it is important; I just wanted to understand if this is intentional or accidental. 1. There is no block form for `Dir#chdir`, unlike `Dir.chdir` (the form that will return to the previous directory when the block is finished) 2. `Dir.chdir` returns `0`, while `Dir#chdir` returns `nil` (both seem to be not representing any particular internal value, just a hardcoded return value). -- https://bugs.ruby-lang.org/