diff options
| author | Eyal Posener <[email protected]> | 2019-10-23 23:03:05 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-10-23 23:03:05 +0300 |
| commit | 98a0c28ec7908620d626d072df3a49c34eadc2b6 (patch) | |
| tree | f2a8af9bf26cb8fca022da1246268969adc2d7ef /args.go | |
| parent | 2f2ff270a9f6adcef8351b1bdf5319b5d612b53f (diff) | |
| parent | f7264fe38585e1c6efe68ea27bc27747fc21cf84 (diff) | |
Merge pull request #102 from posener/sub-cmd-bug
Fix off-by-one error for argument from method
Diffstat (limited to 'args.go')
| -rw-r--r-- | args.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -85,16 +85,17 @@ func splitLastEqual(line []string) []string { return append(line[:len(line)-1], parts...) } +// from returns a copy of Args of all arguments after the i'th argument. func (a Args) from(i int) Args { - if i > len(a.All) { - i = len(a.All) + if i >= len(a.All) { + i = len(a.All) - 1 } - a.All = a.All[i:] + a.All = a.All[i+1:] - if i > len(a.Completed) { - i = len(a.Completed) + if i >= len(a.Completed) { + i = len(a.Completed) - 1 } - a.Completed = a.Completed[i:] + a.Completed = a.Completed[i+1:] return a } |
