From: Johan Holmberg Date: 2003-04-14T21:30:14+09:00 Subject: [patch] fileutils.rb - bug in 'rm_r' Hi ! I believe there is a bug in the "FileUtils.rm_r" method. The error I get if I do $ ruby -rfileutils -e 'FileUtils.rm_r "non-existing"' /home/holmberg/local/lib/ruby/1.8/fileutils.rb:506:in `rm_r': \ undefined method `symlink?' for nil (NoMethodError) ... seem wrong. Such an error (NoMethodError) should problably not be seen by the user of the module. With the patch supplied below the error is changed to $ ruby -I ~ -rfileutils -e 'FileUtils.rm_r "non-existing"' /home/holmberg/fileutils.rb:520:in `lstat': \ No such file or directory - "non-existing" (Errno::ENOENT) ... which is closer to the actual cause of the error (that the file doesn't exist). ( Maybe the error should even be "reformulated" so 'rm_r' complains directly, instead of having 'lstat' do the complaining. ). /Johan Holmberg Index: fileutils.rb =================================================================== RCS file: /src/ruby/lib/fileutils.rb,v retrieving revision 1.17 diff -c -r1.17 fileutils.rb *** fileutils.rb 9 Mar 2003 10:39:50 -0000 1.17 --- fileutils.rb 14 Apr 2003 11:48:15 -0000 *************** *** 519,525 **** begin st = File.lstat(fname) rescue ! next if force end if st.symlink? then remove_file fname, force elsif st.directory? then remove_dir fname, force --- 519,525 ---- begin st = File.lstat(fname) rescue ! force ? next : raise end if st.symlink? then remove_file fname, force elsif st.directory? then remove_dir fname, force