Ah, well...
From "man unlink":
EPERM - The system does not allow unlinking of directories (...). (This is the POSIX prescribed error return; as noted above, Linux returns EISDIR for this case.)
Just one of the many, many examples where POSIX isn't followed through properly in favor of "better" solutions, making it rather worthless as a reference standard.
I agree that it is nice that POSIX came around when the Unixes started to drift apart too much. Most people consider "POSIX" to be a synonym for "Unix-alike", and in that regard, I wouldn't even object.
But as a
standard, it sometimes even forces you to do stuff
wrongly in order to comply. (Leap seconds and Unix time, oh the joy of it...) (*)
And I disagree with much of the underlying philosophy, but that's a different ballgame.
Some day I'll get around to write all the stuff I hate about POSIX into a ranting website. I already got a fitting domain name registered, I just never found the time (or my rants went a bit... overboard.
)
(*): For completeness: Consider an application that writes a log entry every 0.5 seconds. When a leap second occurs, you'll have duplicate, non-sequential timestamps if you're using "Unix time". Jolly fun.