One of the many makefiles in my project shows errors in the error console when there are no files to delete even though the -f flag is being used. Here’s the offending line in the makefile
-rm -f *.o
If I remove the dash at the beginning of the line, it stops dead in its tracks – so I know that this is the line that’s generating the error.
This is a big project with a dozen or so makefiles. What I don’t understand is that some of the others don’t have this problem.
This is the embedded programming world – I’m using WindRiver 2.6 (so the rm utility is “rm.EXE”, though it seems to have the usual options).
Does anyone know why an “rm -f” call would still generate an error if there’s nothing to delete?
I’m not familiar with the WindRiver tools, but here’s an educated guess based on the behavior of typical Unix shells and
maketools.When you run
rm -f *.o, the following happens:*.o, leaving it as is if there are no files matching it (try issuingecho *.oin a dir containing no such files, and one with such files)rm, so if there are no matching files,rmis called with the literal string*.oas its argumentrminterprets as arguments as path names, without expanding patterns (because that’s the shell’s job); the-fshuts it up if a file cannot be foundFrom the error message, it looks like your
rmis broken in that it still complains when no file called*.ocan be found. You can work around this by first checking whether any file matches the pattern. I must admit that I don’t know how to do that in your environment.