rm does not support long-form --recursive, --force on Mac?

This seems crazy, but I just checked in a build script that switched from rm -rf to rm --recursive --force, since it would be more readable. And a collaborator who uses a Mac is reporting this breaks. When I ask him to run rm --help, he gets

5gt2:html-build annevk$ rm --help
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

5gt2:html-build annevk$ rm --force
rm: illegal option -- -
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

This seems crazy to me that such a basic thing would not be supported across different *nixes. Does anyone have a workaround, or at least an explanation?


Solution 1:

OSX is Unix and uses the BSD tools. The extended names are a GNU extension.

You just need to use the standard parameters e.g. -r -f (These are in the POSIX standard)

The error is in the build file using non standard Unix commands

Solution 2:

rm packaged with OS X is the BSD rm which conforms to the POSIX standard. It looks like you were expecting GNU rm.

IIRC, long options are more of a GNU thing.