On 06/11/2010 08:13 AM, Eric Blake wrote: > I would need to understand if there is any difference > between 'rmdir dir' (specified by POSIX) and 'rm -d dir' - if they are > no different, then how do you justify the extension?
I briefly looked at the FreeBSD source code, and there's essentially no difference. The "-d" option causes BSD "rm" to use the rmdir system call rather than the unlink system call. There is a minor difference if you use the "-P" option to shred on the file before removing it, in that "rm -dP" does not attempt to shred a directory, but that minor difference doesn't apply to coreutils where "shred" is a separate executable. I'm dubious about this "rm -d" flag. It's clearly not portable, and (despite a search) I couldn't find any record of anybody seriously using it. On the contrary, all the uses I found of "rm -d" were errors; e.g., people incorrectly thought that "rm -dr FOO" would recursively move the directory tree rooted at FOO. Since "rm -d" causes confusion and provides no extra utility over "rmdir" that I can see, I suggest that we instead change "rm -d" to report an error, much as "rm -X" does for other offbeat values of X.