From 4feb0c477faab159de42d1c524dbf98c83ed3e6d Mon Sep 17 00:00:00 2001 From: Mateus Miranda Date: Fri, 3 Dec 2021 09:32:25 +0100 Subject: [PATCH] Removing sub-command CombinedOutput (#8) --- cfdtunnel/cfdtunnel.go | 9 ++++++--- cfdtunnel/cfdtunnel_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cfdtunnel/cfdtunnel.go b/cfdtunnel/cfdtunnel.go index fb9e8b7..27bb9bf 100644 --- a/cfdtunnel/cfdtunnel.go +++ b/cfdtunnel/cfdtunnel.go @@ -1,7 +1,6 @@ package cfdtunnel import ( - "fmt" "os" "os/exec" "strings" @@ -100,10 +99,14 @@ func (args Arguments) runSubCommand(tunnelConfig TunnelConfig) { } cmd := subCommand{exec.Command(args.Command, args.Args...)} + + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.setupEnvironmentVariables(tunnelConfig.envVars) - output, err := cmd.CombinedOutput() - fmt.Println(string(output)) + err := cmd.Run() if err != nil { log.Errorf("An error occurred trying to run the command %v: %v", args.Command, err) diff --git a/cfdtunnel/cfdtunnel_test.go b/cfdtunnel/cfdtunnel_test.go index 8cbac12..d299921 100644 --- a/cfdtunnel/cfdtunnel_test.go +++ b/cfdtunnel/cfdtunnel_test.go @@ -185,7 +185,7 @@ func TestRunSubCommandStdOut(t *testing.T) { out, _ := ioutil.ReadAll(r) os.Stdout = rescueStdout - assert.Equal(t, "cfdtunnel.go\n\n", string(out)) + assert.Equal(t, "cfdtunnel.go\n", string(out)) } func TestRunSubCommandMissing(t *testing.T) {