Why is it that the following rakefile code works:

task :examples do
   sh %{rm -rf ~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w bench/example.rb}
   sh %{rm -rf ~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w bench/example2.rb}
   sh %{rm -rf ~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w tutorial/example1.rb}
   sh %{rm -rf ~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w tutorial/example2.rb}
end

produces valid output of:

[761 cc1@earwig ~/install/RubyInline-3.0.1]$ rake examples
(in /.autofs/home/s/c/cc1/install/RubyInline-3.0.1)
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example.rb
Type = Inline C , Iter = 1000000, T = 1.59424400 sec, 0.00000159 sec / iter
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example2.rb
hello
hello
hello
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w tutorial/example1.rb
......
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w tutorial/example2.rb
......


but

task :examples do
   rm_rf %{~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w bench/example.rb}
   rm_rf %{~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w bench/example2.rb}
   rm_rf %{~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w tutorial/example1.rb}
   rm_rf %{~/.ruby_inline}
   ruby %{-Ilib/inline.rb -w tutorial/example2.rb}
end

produces:

[762 cc1@earwig ~/install/RubyInline-3.0.1]$ rake examples
(in /.autofs/home/s/c/cc1/install/RubyInline-3.0.1)
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example.rb
Type = Inline C , Iter = 1000000, T = 1.83316400 sec, 0.00000183 sec / iter
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example2.rb
bench/example2.rb:29: undefined method `hello' for #<MyTest:0x4007fa00> 
(NoMethodError)
rake aborted!
Command Failed: [ruby -Ilib/inline.rb -w bench/example2.rb]
../Rakefile:61

both of these tests are using:

ruby 1.8.2 (2004-06-04) [i686-linux]

My assumption is that FileUtils.rm_rf is not actually doing it's job. 
This is validated by the fact that ~/.ruby_inline does not appear to be 
correctly deleted in the second example.

So why is it FileUtils.rm_rf is not doing it's job when it should just 
call through to rm -rf?

Charles Comstock