Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Use echo -n to skip adding newline to external command output #3940

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down