fdupes icon indicating copy to clipboard operation
fdupes copied to clipboard

Exit codes [feature request]

Open NicoWeio opened this issue 3 years ago • 2 comments

A command like fdupes x y prints

fdupes: could not chdir to x
fdupes: could not chdir to y

to stderr if the directories x and y do not exist, but the process has the exit code 0, despite obviously failing. This caused me quite a headache today, because it just assumed that fdupes would give another exit code in such a case.

I don't see anything about exit codes in this GitHub repo nor the man page, so I assume that there are none at the moment. How exactly the error codes should be defined is a question I'm not qualified to answer, but I sure hope they will be added in the future. Thank you!

NicoWeio avatar Jan 02 '22 22:01 NicoWeio

The problem is that failure to chdir into a directory isn't generally a fatal error. It can happen at any time during program execution such as during filesystem traversal any number of directories deep (via --recurse) or after having successfully processed the first n directories listed as command line arguments but failing on argument n+1.

Given all this I choose to treat failure to chdir as a warning instead of an error.

adrianlopezroche avatar Jan 19 '22 21:01 adrianlopezroche

I agree, that's understandable. Nonetheless, one might consider…

  • A flag to change this behavior
  • The special case where none of the given directories could be processed. Then, at least, I'd consider the run failed. (But giving a non-zero exit code only in that case might feel inconsistent as well…)

NicoWeio avatar Jan 19 '22 21:01 NicoWeio