From 44342ba75921eb6da7987ec46f87160f6b8a3631 Mon Sep 17 00:00:00 2001 From: Harsh Vardhan Date: Wed, 3 Oct 2018 10:23:33 +0530 Subject: [PATCH] Use `echo -n` to skip adding newline to external command output Signed-off-by: Harsh Vardhan --- pkg/helpers/helpers_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/helpers/helpers_test.go b/pkg/helpers/helpers_test.go index b45f2bf82b..ee16e5af89 100644 --- a/pkg/helpers/helpers_test.go +++ b/pkg/helpers/helpers_test.go @@ -301,15 +301,13 @@ func TestShellQuote(t *testing.T) { } if runtime.GOOS != "windows" { - out, err := exec.Command("/bin/bash", "-c", "testvar="+actual+"; echo $testvar").Output() + out, err := exec.Command("/bin/bash", "-c", "testvar="+actual+"; echo -n $testvar").Output() if err != nil { t.Errorf("unexpected error : %s", err.Error()) } - o := string(out[:len(out)-1]) //dropping last character as echo prints out a new line as the last character - - if o != test.input { - t.Errorf("failed in Bash output test. Expected %s but got %s", test, o) + if string(out) != test.input { + t.Errorf("failed in Bash output test. Expected %s but got %s", test, out) } } }