7

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?

  • 2
    You really think rm --recursive --force is more readable than rm -rf? Verbosity ≠ readability, especially not when rm -rf is so deeply ingrained in the minds of Unix users everywhere. – Alexis King Sep 6 '15 at 0:38
15

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

4

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.

  • 2
    FWIW, OS X users can brew install coreutils and then use grm. But portable code should just use -rf. – Mathias Bynens Sep 5 '15 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .