From: Christian Brauner Date: Sat, 27 Jan 2018 13:43:14 +0000 (+0100) Subject: tools: make "-n" optional X-Git-Tag: lxc-2.0.10~366 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48a323dfb9a6027b49c52390c4255f4f478a57b3;p=thirdparty%2Flxc.git tools: make "-n" optional This lets users use the tools with "lxc-* -n " or "lxc-* ". Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/arguments.c b/src/lxc/tools/arguments.c index 9a2dcfbb9..711361e0f 100644 --- a/src/lxc/tools/arguments.c +++ b/src/lxc/tools/arguments.c @@ -257,10 +257,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)