[lxc-devel] [lxd/master] Check all alias args to support subcommand aliases
sean-jc on Github
lxc-bot at linuxcontainers.org
Thu Jun 9 17:09:11 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 384 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160609/0350e68e/attachment.bin>
-------------- next part --------------
From dfb91d2d885f6c7dde88f3ea56dab04f8b239114 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <sean.j.christopherson at intel.com>
Date: Thu, 9 Jun 2016 09:46:41 -0700
Subject: [PATCH] Check all alias args to support subcommand aliases
Fixes #2095
Signed-off-by: Sean Christopherson <sean.j.christopherson at intel.com>
---
lxc/main.go | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/lxc/main.go b/lxc/main.go
index 3208ad1..6f8990b 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -189,24 +189,16 @@ func expandAlias(config *lxd.Config, origArgs []string) ([]string, bool) {
aliasKey := []string{}
aliasValue := []string{}
+FindAlias:
for k, v := range config.Aliases {
- matches := false
for i, key := range strings.Split(k, " ") {
- if len(origArgs) <= i+1 {
- break
- }
-
- if origArgs[i+1] == key {
- matches = true
- aliasKey = strings.Split(k, " ")
- aliasValue = strings.Split(v, " ")
- break
+ if len(origArgs) <= i+1 || origArgs[i+1] != key {
+ continue FindAlias
}
}
- if !matches {
- continue
- }
+ aliasKey = strings.Split(k, " ")
+ aliasValue = strings.Split(v, " ")
foundAlias = true
break
More information about the lxc-devel
mailing list