$ perl -le 'print -f "/dev/null" ? "IS" : "is NOT", " a file"'
is NOT a file
but it's also true that sometimes -e gets overused when a more restrictive check would have been better, for example at least checking ! -d.
Update: Just to clarify what I meant with the above example: If a user is supposed to supply a filename to a program, then in a lot of cases the program shouldn't reject /dev/null and just work with it as if it was a regular file. Of course there might be cases where a program would want to accept only regular files - but then again, -f also returns true if what's being tested is a symbolic link to a file, so one would have to check for that specially too. |