I've always kind of wondered why rmdir(2) only deletes empty directories. (I suppose it could be simply to keep the recursive directory traversal logic out of the kernel.) One can usually just recursively delete directories so this doesn't matter but I ran across a situation where it does actually matter that rmdir only deletes empty directories that I hadn't considered before.

If directory /containing is writable by user u and directory /containing/private is not writable by user u, then u can delete /containing/private only if /containing/private is empty.

This kind of feels like it's a security/access control choice. Does anyone know if this scenario was an explicit consideration when the rmdir system call was being designed? (The macOS man page suggests that rmdir(2) appeared in 4.2BSD.)

@stevecheckoway Even if you can't write /containing/private you can rename it somewhere else. This is fundamental to the directory permissions model.
@dalias I've never thought about needing to move a directory not owned by my user except as root.