scrot icon indicating copy to clipboard operation
scrot copied to clipboard

`scrot /tmp/` creates "/tmp/_000"

Open guijan opened this issue 2 years ago • 2 comments

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?

guijan avatar Mar 17 '23 09:03 guijan

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.

N-R-K avatar Jul 03 '23 06:07 N-R-K

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).

N-R-K avatar Jul 03 '23 09:07 N-R-K