Repository: spf13/cobra (go)

Issue:
Two newlines between Aliases and Flags in help
Now you can see two newlines instead of one between Aliases and Flags in help:
![2017-04-01 23 00 00](https://cloud.githubusercontent.com/assets/13235519/24582379/3ae5ebec-172f-11e7-8259-02d9e653c6b3.png)

But should be like this:
![2017-04-01 23 00 51](https://cloud.githubusercontent.com/assets/13235519/24582383/43e595da-172f-11e7-89a2-a73f2e457787.png)


Pull request:
Keep only one newline between Aliases and Flags in help
Fix #409

Patch:
diff --git a/bash_completions.go b/bash_completions.go
index 8820ba8..a0d0402 100644
--- a/bash_completions.go
+++ b/bash_completions.go
@@ -88,8 +88,8 @@ __handle_reply()
                 local index flag
                 flag="${cur%%=*}"
                 __index_of_word "${flag}" "${flags_with_completion[@]}"
+                COMPREPLY=()
                 if [[ ${index} -ge 0 ]]; then
-                    COMPREPLY=()
                     PREFIX=""
                     cur="${cur#*=}"
                     ${flags_completion[${index}]}
@@ -225,7 +225,7 @@ __handle_command()
     fi
     c=$((c+1))
     __debug "${FUNCNAME[0]}: looking for ${next_command}"
-    declare -F $next_command >/dev/null && $next_command
+    declare -F "$next_command" >/dev/null && $next_command
 }
 
 __handle_word()
diff --git a/command.go b/command.go
index 664bf5a..f4cd95c 100644
--- a/command.go
+++ b/command.go
@@ -113,7 +113,7 @@ type Command struct {
 	flagErrorBuf *bytes.Buffer
 
 	args          []string             // actual args parsed from flags
-	output        *io.Writer           // out writer if set in SetOutput(w)
+	output        io.Writer            // out writer if set in SetOutput(w)
 	usageFunc     func(*Command) error // Usage can be defined by application
 	usageTemplate string               // Can be defined by Application
 	flagErrorFunc func(*Command, error) error
@@ -141,7 +141,7 @@ func (c *Command) SetArgs(a []string) {
 // SetOutput sets the destination for usage and error messages.
 // If output is nil, os.Stderr is used.
 func (c *Command) SetOutput(output io.Writer) {
-	c.output = &output
+	c.output = output
 }
 
 // SetUsageFunc sets usage function. Usage can be defined by application.
@@ -199,7 +199,7 @@ func (c *Command) OutOrStderr() io.Writer {
 
 func (c *Command) getOut(def io.Writer) io.Writer {
 	if c.output != nil {
-		return *c.output
+		return c.output
 	}
 	if c.HasParent() {
 		return c.parent.getOut(def)
@@ -341,8 +341,7 @@ func (c *Command) UsageTemplate() string {
   {{ .CommandPath}} [command]{{end}}{{if gt .Aliases 0}}
 
 Aliases:
-  {{.NameAndAliases}}
-{{end}}{{if .HasExample}}
+  {{.NameAndAliases}}{{end}}{{if .HasExample}}
 
 Examples:
 {{ .Example }}{{end}}{{if .HasAvailableSubCommands}}


Test patch:
diff --git a/command_test.go b/command_test.go
index 7947f6c..8b78ee3 100644
--- a/command_test.go
+++ b/command_test.go
@@ -191,6 +191,14 @@ func TestEnableCommandSortingIsDisabled(t *testing.T) {
 	EnableCommandSorting = true
 }
 
+func TestSetOutput(t *testing.T) {
+	cmd := &Command{}
+	cmd.SetOutput(nil)
+	if out := cmd.OutOrStdout(); out != os.Stdout {
+		t.Fatalf("expected setting output to nil to revert back to stdout, got %v", out)
+	}
+}
+
 func TestFlagErrorFunc(t *testing.T) {
 
 	cmd := &Command{