The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7880
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This allows things like: - lxc --project=blah shell abc - lxc --debug shell abc Not that it aliases cannot support leading flags with value separated by spaces as the alias handling logic does not know what flag is a boolean and what flag takes a value. As a result, use `lxc --project=blah shell` and not `lxc --project blah shell` as the latter cannot work and will lead to a confusing error. Closes #7625 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 50373fef4298d343ef64d8375c2706347f77b7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 16 Sep 2020 16:28:13 -0400 Subject: [PATCH] lxc: Better handle arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows things like: - lxc --project=blah shell abc - lxc --debug shell abc Not that it aliases cannot support leading flags with value separated by spaces as the alias handling logic does not know what flag is a boolean and what flag takes a value. As a result, use `lxc --project=blah shell` and not `lxc --project blah shell` as the latter cannot work and will lead to a confusing error. Closes #7625 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxc/main_aliases.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lxc/main_aliases.go b/lxc/main_aliases.go index 6367d6ae55..fd37122339 100644 --- a/lxc/main_aliases.go +++ b/lxc/main_aliases.go @@ -48,7 +48,7 @@ func expandAlias(conf *config.Config, args []string) ([]string, bool) { var newArgs []string var origArgs []string - for _, arg := range args { + for _, arg := range args[1:] { if arg[0] != '-' { break } @@ -56,7 +56,7 @@ func expandAlias(conf *config.Config, args []string) ([]string, bool) { newArgs = append(newArgs, arg) } - origArgs = args[len(newArgs):] + origArgs = append([]string{args[0]}, args[len(newArgs)+1:]...) aliasKey, aliasValue, foundAlias := findAlias(conf.Aliases, origArgs) if !foundAlias { @@ -67,7 +67,7 @@ func expandAlias(conf *config.Config, args []string) ([]string, bool) { } if !strings.HasPrefix(aliasValue[0], "/") { - newArgs = append(newArgs, origArgs[0]) + newArgs = append([]string{origArgs[0]}, newArgs...) } hasReplacedArgsVar := false
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel