Bugzilla – Bug 1150156
snapper create: misleading error message
Last modified: 2020-08-31 11:40:32 UTC
When snapper create is executed with an unknown parameter, the message creates confusion: "Command 'create' does not take arguments." Including devel project filesystems:snapper/snapper -> snapper-0.8.3/client/snapper.cc, the command does accept arguments: 625 void 626 command_create(ProxySnappers* snappers, ProxySnapper* snapper) 627 { 628 const struct option options[] = { 629 { "type", required_argument, 0, 't' }, 630 { "pre-number", required_argument, 0, 0 }, 631 { "print-number", no_argument, 0, 'p' }, 632 { "description", required_argument, 0, 'd' }, 633 { "cleanup-algorithm", required_argument, 0, 'c' }, 634 { "userdata", required_argument, 0, 'u' }, 635 { "command", required_argument, 0, 0 }, 636 { 0, 0, 0, 0 } 637 }; 638 639 GetOpts::parsed_opts opts = getopts.parse("create", options); 640 if (getopts.hasArgs()) 641 { 642 cerr << _("Command 'create' does not take arguments.") << endl; 643 exit(EXIT_FAILURE); 644 } But, the message is wrong. Reproducible: Having an openSUSE/SLE installation with enabled BTRFS snapshots, execute: # snapper create -type single -d "single snapshot" Notice the bad argument -type.
Thank you Sergio. Maybe the error message could be improved a little bit.
I forgot to state a expected result: "Invalid parameter for command 'create'."
Well, the error message is not wrong. The problem is that the invocation contains two errors: 1. The type is "ype" and 2. an additional argument is provided. snapper reports the second error. This is like with the --width option of ls: # ls --width 1000 ok # ls -width 1000 ls: invalid line width: ‘idth’ # ls -w1000 1000 ls: cannot access '1000': No such file or directory So ls also reports just one error but the other one. A better result for snapper could be: # snapper create -type single Unknown snapshot type 'ype'.
I found some real bugs in the error handling for getopt in snapper: # snapper create -pt Missing argument for command option '-pt'. The error should only mention '-t' or '--type' that needs the argument. # snapper create -px Unknown option '-px' for command 'create'. The error should only mention '-x'.
PR: https://github.com/openSUSE/snapper/pull/550
SR: https://build.opensuse.org/request/show/830770