End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
FileUtils#chdir
chdir(dir, verbose: nil)
lib/fileutils.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/fileutils.rb, line 137
def cd(dir, verbose: nil, &block) # :yield: dir
fu_output_message "cd #{dir}" if verbose
result = Dir.chdir(dir, &block)
fu_output_message 'cd -' if verbose and block
result
end
Alias of #cd
Changes the current directory to the directory dir.
If this method is called with block, resumes to the previous working directory after the block execution has finished.
Example
FileUtils.cd('/') # change directory FileUtils.cd('/', verbose: true) # change directory and report it FileUtils.cd('/') do # change directory # ... # do something end # return to original directory