You are using the $ anchor instead of the \z anchor which means that the directory will be considered empty if there is a valid file named ".\n" or "..\n".
In reply to Re^2: How to tell if a Directory is Empty
by jwkrahn
in thread How to tell if a Directory is Empty
by ishootperls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |