From b1a76360e743e8e977833865f083c1d53c065f1d Mon Sep 17 00:00:00 2001
From: Abubakr-Sadik Nii Nai Davis <dwa2pac@gmail.com>
Date: Tue, 4 Jul 2017 17:04:31 +0000
Subject: [PATCH] Do not clutter the output with error messages from commands
 in the audit pipeline.

---
 check/check.go | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/check/check.go b/check/check.go
index afab79a..c912d98 100644
--- a/check/check.go
+++ b/check/check.go
@@ -63,7 +63,7 @@ type Check struct {
 // Run executes the audit commands specified in a check and outputs
 // the results.
 func (c *Check) Run() {
-	var out bytes.Buffer
+	var out, serr bytes.Buffer
 
 	// Check if command exists or exit with WARN.
 	for _, cmd := range c.Commands {
@@ -87,7 +87,8 @@ func (c *Check) Run() {
 	//   cmd0 err should terminate chain
 	cs := c.Commands
 
-	cs[0].Stderr = os.Stderr
+	// Initialize command pipeline
+	cs[0].Stderr = &serr
 	cs[n-1].Stdout = &out
 	i := 1
 
@@ -99,27 +100,26 @@ func (c *Check) Run() {
 			os.Exit(1)
 		}
 
-		cs[i].Stderr = os.Stderr
+		cs[i].Stderr = &serr
 		i++
 	}
 
+	// Start command pipeline
 	i = 0
 	for i < n {
-		err := cs[i].Start()
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "%s: %s\n", cs[i].Args, err)
-			os.Exit(1)
-		}
+		cs[i].Start()
+		i++
+	}
 
-		errw := cs[i].Wait()
-		if err != nil {
-			fmt.Fprintf(os.Stderr, "%s: %s\n", cs[i].Args, errw)
-			os.Exit(1)
-		}
+	// Complete command pipeline
+	i = 0
+	for i < n {
+		cs[i].Wait()
 
 		if i < n-1 {
 			cs[i].Stdout.(io.Closer).Close()
 		}
+
 		i++
 	}
 
-- 
GitLab