fix getopt when invoking without arguments
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 6 Jun 2018 04:24:32 +0000 (06:24 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 7 Jun 2018 05:09:59 +0000 (07:09 +0200)
src/PVE/JSONSchema.pm

index 0e722b8..f014dc3 100644 (file)
@@ -1406,6 +1406,16 @@ sub get_options {
            raise("too many arguments\n", code => HTTP_BAD_REQUEST)
                if scalar(@$args) != 0;
        }
+    } else {
+       if (ref($arg_param)) {
+           foreach my $arg_name (@$arg_param) {
+               if ($arg_name eq 'extra-args') {
+                   $opts->{'extra-args'} = [];
+               } else {
+                   raise("not enough arguments\n", code => HTTP_BAD_REQUEST);
+               }
+           }
+       }
     }
 
     if (my $pd = $schema->{properties}->{password}) {