From: Keith Busch Date: Wed, 3 Jan 2018 23:03:36 +0000 (-0700) Subject: Allow hierarchy of similiarly named plugins X-Git-Tag: v1.6~135 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2fa5d558d33da4da59331478798a0a1ef5e8f6ea;p=users%2Fhch%2Fnvme-cli.git Allow hierarchy of similiarly named plugins For historical reasons, we allow the user to write their command line executing "vendor" plugin "command" as one of two ways: nvme vendor command And nvme vendor-command This was conflicting if a hierarchy of vendor additions exists, like "vendor-oem". So, this patch fixes that by first searching the entire builtin vendor plugins before searching for matching substrings. Signed-off-by: Keith Busch --- diff --git a/plugin.c b/plugin.c index ba0f55b..a9bf6cd 100644 --- a/plugin.c +++ b/plugin.c @@ -160,9 +160,13 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin) while (extension) { if (!strcmp(str, extension->name)) return handle_plugin(argc - 1, &argv[1], extension); + extension = extension->next; + } - /* If the command is executed with the extension name and - * command together ("plugin-command"), run the plug in */ + /* If the command is executed with the extension name and + * command together ("plugin-command"), run the plug in */ + extension = plugin->next; + while (extension) { if (!strncmp(str, extension->name, strlen(extension->name))) { argv[0] += strlen(extension->name); while (*argv[0] == '-')