Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cebtenzzre opened this issue Dec 29, 2020 · 2 comments
Closed

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

cebtenzzre opened this issue Dec 29, 2020 · 2 comments
Assignees

Comments

@cebtenzzre
Copy link
Contributor

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

@SeeSpotRun
Copy link
Collaborator

Yes you are correct; it is sloppy.

@SeeSpotRun
Copy link
Collaborator

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

Thanks for the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants