From: Eric Hodel Date: 2011-01-25T03:58:23+09:00 Subject: Re: FileUtils writing to stderr On Jan 24, 2011, at 09:32, Eric Hodel wrote: > On Jan 24, 2011, at 5:25, "Mark L." wrote: >> Hi there, >> >> I'm having a few issues with FileUtils writing stuff to stderr when no error has occurred. For example I might have the following simple >> Rakefile: >> >> require 'rake' >> task :clean do >> rm_rf 'test' >> end > > Note that rake's rm_rf is not exactly FileUtils' rm_rf > >> When I run >> >> rake clean 2> err >> >> In the err file I see: >> >> 'rm -rf test' >> >> I would expect this to be sent to stdout rather than err. > > Why? I expect informational messages on stderr. This way rake's messages don't interfere with a rake user's output. By having rake's messages on stderr a rake task author can write tasks that can be piped to other commands. > > rake email | sendmail # for example > > (Yes, rake currently outputs a message on stdout. I have fixed that in trunk.) > >> The problem that I have is that I am trying to detect a rake failure from within ant. Rake doesn't seem to return the correct error code so I was testing for failure by detecting if anything was written to stderr. > > You should query $?, not stderr. Rake should be behaving like a standard unix command. > >> My ant task would thus look something like this: >> >> >> >> >> >> >> >> >> This works fine except when I try to use the FileUtils methods. rm_rf causes it to fail as does mkdir_p. >> >> Any suggestions? > > AFAIK rm -rf and mkdir -p always exit 0. My mistake, these can exit 1. I suppose the question then is "what does rm -f mean for rake's exit status?" If I'm writing a clean task that uses rm -f I suppose I'm saying it's OK for clean to not delete some things. > What is your rake task that exits 0 improperly?