The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7628

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) ===
Closes #7625

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 8c62fcd457017fd94946c369af4cc21425d6a2a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Mon, 6 Jul 2020 14:47:41 -0400
Subject: [PATCH] lxc/main_alias: Handle leading arguments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #7625

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxc/main_aliases.go | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lxc/main_aliases.go b/lxc/main_aliases.go
index dc35a3140e..6367d6ae55 100644
--- a/lxc/main_aliases.go
+++ b/lxc/main_aliases.go
@@ -44,7 +44,20 @@ func findAlias(aliases map[string]string, origArgs []string) 
([]string, []string
        return aliasKey, aliasValue, foundAlias
 }
 
-func expandAlias(conf *config.Config, origArgs []string) ([]string, bool) {
+func expandAlias(conf *config.Config, args []string) ([]string, bool) {
+       var newArgs []string
+       var origArgs []string
+
+       for _, arg := range args {
+               if arg[0] != '-' {
+                       break
+               }
+
+               newArgs = append(newArgs, arg)
+       }
+
+       origArgs = args[len(newArgs):]
+
        aliasKey, aliasValue, foundAlias := findAlias(conf.Aliases, origArgs)
        if !foundAlias {
                aliasKey, aliasValue, foundAlias = findAlias(defaultAliases, 
origArgs)
@@ -53,7 +66,6 @@ func expandAlias(conf *config.Config, origArgs []string) 
([]string, bool) {
                }
        }
 
-       var newArgs []string
        if !strings.HasPrefix(aliasValue[0], "/") {
                newArgs = append(newArgs, origArgs[0])
        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to