I like `rmdir` because I don't have to check if a directory that I think is empty is actually empty with `ls -la` before removing it. This happens a lot with moving stuff out of directories (sometimes to different destinations).
Even in that case, you can use "rm -d" instead of "rmdir".
% mkdir herewulf
% rm herewulf
rm: herewulf: is a directory
% rm -d herewulf
%
% mkdir herewulf
% touch herewulf/nonempty.txt
%
% rm herewulf/
rm: herewulf/: is a directory
% rm -d herewulf/
rm: herewulf/: Directory not empty
% rm herewulf/nonempty.txt
% rm -d herewulf/
The only distinct feature of rmdir is that it won't remove things that aren't files: % touch herewulf
% rm -d herewulf
% touch herewulf
% rmdir herewulf
rmdir: herewulf: Not a directory
Is that "one thing well" really enough to justify its own tool?Unix has always had a tension between "one thing well" and "one powerful tool".
Is 'cc' a preprocessor? A compiler? A linker? Yes!
Does 'date' show the current date (and time), set the system date, or convert between dates? Yes!
> Is 'cc' a preprocessor? A compiler? A linker? Yes!
It's none of them; it's a driver which calls the preprocessor (cpp), the real compiler, and the linker (ld).
The man pages call it a compiler:
% man cc
...
DESCRIPTION
clang is a C, C++, and Objective-C compiler which encompasses
preprocessing, parsing, optimization, code generation, assembly, and
linking.
% man gcc
...
NAME
gcc - GNU project C and C++ compiler
...
For me, Perl shows just how restricted that viewpoint was.
After I learned Perl, I stopped caring about tr, and sed, and many of the other "one thing well" command-line tools. And I've no desire to swap out and modify the 's//' component of perl.
Perl does "one thing" - interpret Perl programs - even though it also replaces many things.
I know 'rmdir' exists. It does one thing, well - remove an empty directory. It's been around since the first release of Unix.
However, I use "rm -rf" because it's easier to use a more powerful tool which handles empty directory removal as a special case.
You can also change your viewpoint and say that Fossil does do one thing well: it's a distributed project control system. That's a new category I just made up, to highlight just how subjective "one thing" is.