In the case an iprconfig CLI command (-c <cmd>) accepts an argument with the same name as one used by the iprconfig parser, the later will interpret it as a global iprconfig argument, and not pass it to the command specific parser. For instance, a command line like this:
$ iprconfig -c raid-create -r 0 -c writeback ... will fail, because the second '-c' is interpreted as an iprconfig command, instead of an argument that must be passed to raid-create. This patch raises the precedence of arguments in parsing, so anything after the first '-c' will be interpreted as a command argument instead of a global argument to iprconfig. Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com> --- iprconfig.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/iprconfig.c b/iprconfig.c index 2addf16..cfccefe 100644 --- a/iprconfig.c +++ b/iprconfig.c @@ -18757,16 +18757,6 @@ int main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (parse_option(argv[i])) continue; - else if (strcmp(argv[i], "-e") == 0) - next_editor = 1; - else if (strcmp(argv[i], "-k") == 0) - next_dir = 1; - else if (strcmp(argv[i], "-c") == 0) - next_cmd = 1; - else if (strcmp(argv[i], "-l") == 0) { - list_options(); - exit(1); - } else if (next_editor) { strcpy(parm_editor, argv[i]); next_editor = 0; @@ -18783,7 +18773,17 @@ int main(int argc, char *argv[]) add_args[num_add_args] = malloc(strlen(argv[i]) + 1); strcpy(add_args[num_add_args], argv[i]); num_add_args++; - } else { + } else if (strcmp(argv[i], "-e") == 0) { + next_editor = 1; + } else if (strcmp(argv[i], "-k") == 0) { + next_dir = 1; + } else if (strcmp(argv[i], "-c") == 0) { + next_cmd = 1; + } else if (strcmp(argv[i], "-l") == 0) { + list_options(); + exit(1); + } + else { usage(); exit(1); } -- 2.1.0 ------------------------------------------------------------------------------ _______________________________________________ Iprdd-devel mailing list Iprdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iprdd-devel