I've been checking if a file exists and that the file size is greater than 0 like this:
if ($foo &&
-e '/path/' . $foo &&
-s '/path/' . $foo > 0) {
# do stuff
}
The question is, do I
really need to check if $foo exists, then both -e and -s? I feel like the answer is no... if it doesn't exist then the file size would not be greater than 0, so it would fail. Right? My tests all come out as expected, but it's been so long since I've built it I can't remember why I did both.
If the concern is that a file not existing would return "false" or "undefined" that would confuse the match, then I could always do this:
if ((-s '/path/' . $foo // 0) > 0) {
# do stuff
}
Thoughts?