Skip to content

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

@cebtenzzre

Description

@cebtenzzre

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:

rmlint/lib/cmdline.c

Lines 1604 to 1607 in 6abfba9

if(cfg->dedupe) {
/* dedupe session; regular rmlint configs are ignored */
goto cleanup;
}

But this TODO is over three years old, maybe it's time for it to be resolved?

rmlint/lib/cmdline.c

Lines 1538 to 1549 in 6abfba9

/* TODO: move subcommands to separate option parser
* e.g.
* Usage:
* rmlint [options] <paths>...
* rmlint --subcommand [options]
* Subcommands (must be first arg):
* --dedupe Dedupe matching extents from source to dest (if filesystem supports)
* --is-reflink Test if two files are reflinks
* --gui Launch rmlint gui
* For help on subcommands use rmlint --<subcommand> --help
*
*/

Software Versions

rmlint 2.10.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions