`scrot /tmp/` creates "/tmp/_000"
The code checks if /tmp/ already exists, and because it does, it appends _000 and creates that instead. We can't create the file because a directory by that name already exists, so we create a file inside it? This is a funny quirk rather than something intentional.
The code should probably error in this case.
But what should we do about cd / && scrot tmp? Nothing, possibly?
But what should we do about
cd / && scrot tmp? Nothing, possibly?
Attempting tmp_000 is probably not a bad idea in that case. I can imagine someone doing something like scrot test trying to create a file test but it already might exist as a directory. In which case test_000 isn't too unexpected of an outcome.
OOTH if someone invokes scrot with a trailing slash (e.g /tmp/), then we can:
A. Error out early (similar to #361)
B. Strip all trailing slashes from the filename so it behaves as if /tmp was specified in the cli.
I'm in favor of (A) because it seems less surprising than having your explicit trailing slash stripped silently.
I guess there's also option C
C. Interpret a trailing slash as a output dir. E.g scort /tmp/ would create a file inside of /tmp with the default output format.
Personally, I don't like this. It overloads the output filename with yet another functionality (currently we use output filename's extension to determine format also).
(This also made me realize that scrot's extension detection is still broken: scrot ~/.config/testfile will end up trying to use config/testfile as opt.format).