
Issue #20056 has been updated by zverok (Victor Shepelev).
Not passing an argument to the block in the Dir.fchdir or Dir#chdir case makes sense to me.
Yup, I can see the reasoning, that's why I don't think it is a big problem. (I thought that may be passing `self`, i.e. an instance of `Dir` inside the block might be a good idea, but the implementation doesn't allow that.) On the other hand, the return value of the block in `#chdir` case should be fixed, don't you think? I think this should do, probably... ```diff dir_chdir(VALUE dir) { #if defined(HAVE_FCHDIR) && defined(HAVE_DIRFD) && HAVE_FCHDIR && HAVE_DIRFD - dir_s_fchdir(rb_cDir, dir_fileno(dir)); + return dir_s_fchdir(rb_cDir, dir_fileno(dir)); #else VALUE path = dir_get(dir)->path; - dir_s_chdir(1, &path, rb_cDir); + return dir_s_chdir(1, &path, rb_cDir); #endif - - return Qnil; } ``` ---------------------------------------- Misc #20056: Dir#chdir inconsistency with Dir.chdir https://bugs.ruby-lang.org/issues/20056#change-105632 * 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/