From 8b764aac7182931301381409f907247118da0785 Mon Sep 17 00:00:00 2001 From: sharat Date: Fri, 9 Sep 2016 01:58:33 +0530 Subject: [PATCH] ctlv3: fix line parsing for Windows --- etcdctl/ctlv3/command/txn_command.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/etcdctl/ctlv3/command/txn_command.go b/etcdctl/ctlv3/command/txn_command.go index 033f0ba349d..d5e75b05b47 100644 --- a/etcdctl/ctlv3/command/txn_command.go +++ b/etcdctl/ctlv3/command/txn_command.go @@ -77,12 +77,13 @@ func readCompares(r *bufio.Reader) (cmps []clientv3.Cmp) { if err != nil { ExitWithError(ExitInvalidInput, err) } - if len(line) == 1 { + + // remove space from the line + line = strings.TrimSpace(line) + if len(line) == 0 { break } - // remove trialling \n - line = line[:len(line)-1] cmp, err := parseCompare(line) if err != nil { ExitWithError(ExitInvalidInput, err) @@ -99,12 +100,13 @@ func readOps(r *bufio.Reader) (ops []clientv3.Op) { if err != nil { ExitWithError(ExitInvalidInput, err) } - if len(line) == 1 { + + // remove space from the line + line = strings.TrimSpace(line) + if len(line) == 0 { break } - // remove trialling \n - line = line[:len(line)-1] op, err := parseRequestUnion(line) if err != nil { ExitWithError(ExitInvalidInput, err)