rm -rf versus -rm -rf

It means that make itself will ignore any error code from rm.

In a makefile, if any command fails then the make process itself discontinues processing. By prefixing your commands with -, you notify make that it should continue processing rules no matter the outcome of the command.

For example, the makefile rule:

clean:
    rm *.o
    rm *.a

will not remove the *.a files if rm *.o returns an error (if, for example, there aren’t any *.o files to delete). Using:

clean:
    -rm *.o
    -rm *.a

will fix that particular problem.


Aside: Although it’s probably not needed in your specific case (since the -f flag appears to prevent rm from returning an error when the file does not exist), it’s still good practice to mark the line explicitly in the makefilerm may return other errors under certain circumstances and it makes your intent clear.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)