]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/JSONSchema.pm
get_options: avoid warning for -list format
[pve-common.git] / src / PVE / JSONSchema.pm
index ed1813d3bb2a66b4d2f41cc33a58f05acaa020a7..32d461cbf6467e6ad7adbdd86b650df79e7f7228 100644 (file)
@@ -1082,6 +1082,8 @@ sub get_options {
        }
     }
 
+    Getopt::Long::Configure('prefix_pattern=(--|-)');
+
     my $opts = {};
     raise("unable to parse option\n", code => HTTP_BAD_REQUEST)
        if !Getopt::Long::GetOptionsFromArray($args, $opts, @getopt);
@@ -1137,7 +1139,7 @@ sub get_options {
                if ($pd->{format} =~ m/-list/) {
                    # allow --vmid 100 --vmid 101 and --vmid 100,101
                    # allow --dow mon --dow fri and --dow mon,fri
-                   $opts->{$p} = join(",", @{$opts->{$p}});
+                   $opts->{$p} = join(",", @{$opts->{$p}}) if ref($opts->{$p}) eq 'ARRAY';
                } elsif ($pd->{format} =~ m/-alist/) {
                    # we encode array as \0 separated strings
                    # Note: CGI.pm also use this encoding