aboutsummaryrefslogtreecommitdiffstats
path: root/cli/parser.go
diff options
context:
space:
mode:
authorPetter Rasmussen2016-01-22 23:00:45 +0100
committerPetter Rasmussen2016-01-22 23:00:45 +0100
commit1fe1ad062175bca2891182698338a7bd40ce8982 (patch)
treec4efcf0d43df2a7d66be3d41b9c5446cdb6e4c05 /cli/parser.go
parentf90c11bfefcb7b82cb1032b0c43e3b35db4c2e73 (diff)
downloadgdrive-1fe1ad062175bca2891182698338a7bd40ce8982.tar.bz2
Copy slice
Diffstat (limited to 'cli/parser.go')
-rw-r--r--cli/parser.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/cli/parser.go b/cli/parser.go
index e80750e..50bd0bd 100644
--- a/cli/parser.go
+++ b/cli/parser.go
@@ -291,7 +291,7 @@ type CompleteParser struct {
}
func (self CompleteParser) Match(values []string) ([]string, bool) {
- remainingValues := values
+ remainingValues := copySlice(values)
for _, parser := range self.parsers {
var ok bool
@@ -305,7 +305,7 @@ func (self CompleteParser) Match(values []string) ([]string, bool) {
}
func (self CompleteParser) Capture(values []string) ([]string, map[string]interface{}) {
- remainingValues := values
+ remainingValues := copySlice(values)
data := map[string]interface{}{}
for _, parser := range self.parsers {
@@ -349,3 +349,9 @@ func flagKeyMatch(key string, values []string, index int) ([]string, bool) {
return flagKeyMatch(key, values, index + 1)
}
+
+func copySlice(a []string) []string {
+ b := make([]string, len(a))
+ copy(b, a)
+ return b
+}