tools: make "-n" optional

This lets users use the tools with "lxc-* -n <container-name>" or
"lxc-* <container-name>".

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-01-27 14:43:14 +01:00
parent b28e282611
commit 817a0e46b6
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -256,10 +256,18 @@ extern int lxc_arguments_parse(struct lxc_arguments *args, int argc,
}
/* Check the command options */
if (!args->name && strcmp(args->progname, "lxc-autostart") != 0) {
lxc_error(args, "missing container name, use --name option");
return -1;
if (args->argv) {
args->name = argv[optind];
optind++;
args->argv = &argv[optind];
args->argc = argc - optind;
}
if (!args->name) {
lxc_error(args, "No container name specified");
return -1;
}
}
if (args->checker)