sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.87k stars 130 forks source link

--is-reflink mode uses main option parsing #458

Closed cebtenzzre closed 3 years ago

cebtenzzre commented 3 years ago

Since the --is-reflink mode (documented as a "stand-alone command") uses the main option parsing code, it behaves differently from what the docs suggest.

Steps to Reproduce

$ touch a
$ touch b
$ ls rmlint.sh rmlint.json
ls: cannot access 'rmlint.sh': No such file or directory
ls: cannot access 'rmlint.json': No such file or directory

$ rmlint --is-reflink a b -o summary:stdout
$ ls rmlint.sh rmlint.json
ls: cannot access 'rmlint.sh': No such file or directory
ls: cannot access 'rmlint.json': No such file or directory

$ rmlint --is-reflink a b
$ ls rmlint.sh rmlint.json
rmlint.json  rmlint.sh

Actual Behavior

rmlint --is-reflink accepts the -o option, and creates useless output files unless -o is used.

Expected Behavior

I would expect rmlint --is-reflink to behave like a subcommand. It should accept only the options -v and -V as per the documentation, and should not call rm_cmd_set_outputs -> rm_cmd_set_default_outputs -> rm_fmt_add(session->formats, "sh", "rmlint.sh").

It could at least be special-cased like --dedupe is here: https://github.com/sahib/rmlint/blob/6abfba9af35dd89f6dc82bbfdf5957875a19db15/lib/cmdline.c#L1604-L1607

But this TODO is over three years old, maybe it's time for it to be resolved? https://github.com/sahib/rmlint/blob/6abfba9af35dd89f6dc82bbfdf5957875a19db15/lib/cmdline.c#L1538-L1549

Software Versions

rmlint 2.10.1

SeeSpotRun commented 3 years ago

Yes you are correct; it is sloppy.

SeeSpotRun commented 3 years ago

Done and merged into https://github.com/sahib/rmlint/tree/develop.

Thanks for the input.