1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-07 21:18:59 +03:00

Ignore hyphens in long option names

The hyphens are removed from long option names before
being read.  This means that:

- Option name specifications in args.h must not include hyphens.
  (The hyphen in 'use-policies' is removed.)

- A user can include hyphens anywhere in the option name.
  All the following are equivalent:
  --vgmetadatacopies,
  --vg-metadata-copies,
  --v-g-m-e-t-a-d-a-t-a-c-o-p-i-e-s-
This commit is contained in:
David Teigland 2015-06-16 09:35:52 -05:00
parent 7fe5e4010c
commit 1f318dbcee
2 changed files with 26 additions and 1 deletions

View File

@ -117,7 +117,7 @@ arg(cachesettings_ARG, '\0', "cachesettings", string_arg, ARG_GROUPABLE)
arg(unconfigured_ARG, '\0', "unconfigured", NULL, 0)
arg(units_ARG, '\0', "units", string_arg, 0)
arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
arg(use_policies_ARG, '\0', "use-policies", NULL, 0)
arg(use_policies_ARG, '\0', "usepolicies", NULL, 0)
arg(validate_ARG, '\0', "validate", NULL, 0)
arg(version_ARG, '\0', "version", NULL, 0)
arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0)

View File

@ -16,8 +16,33 @@
#include "tools.h"
#include "lvm2cmdline.h"
#define MAX_ARG_LEN 64
int main(int argc, char **argv)
{
char arg_new[MAX_ARG_LEN];
char *arg;
int i, j, j_new;
for (i = 1; i < argc; i++) {
arg = argv[i];
if (arg[0] == '-' && arg[1] == '-' && strlen(arg) < MAX_ARG_LEN) {
memset(arg_new, 0, sizeof(arg_new));
arg_new[0] = '-';
arg_new[1] = '-';
for (j = 2, j_new = 2; j < strlen(arg) + 1; j++) {
if (arg[j] == '-')
continue;
arg_new[j_new] = arg[j];
j_new++;
}
memcpy(argv[i], arg_new, strlen(arg_new) + 1);
}
}
return lvm2_main(argc, argv);
}