From 64400adf086cee3a01f68a19f9d878aea04f22ee Mon Sep 17 00:00:00 2001 From: Tim Reddehase Date: Wed, 26 Sep 2018 11:04:11 +0200 Subject: [PATCH] deal with unreachable code warning. --- fish_completions.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fish_completions.go b/fish_completions.go index 95f47b0bb..dac814008 100644 --- a/fish_completions.go +++ b/fish_completions.go @@ -119,6 +119,9 @@ func flagRequiresArgumentCompletion(flag *pflag.Flag) string { func subCommandPath(rootCmd *Command, cmd *Command) string { path := []string{} currentCmd := cmd + if rootCmd == cmd { + return "" + } for { path = append([]string{currentCmd.Name()}, path...) if currentCmd.Parent() == rootCmd { @@ -126,7 +129,6 @@ func subCommandPath(rootCmd *Command, cmd *Command) string { } currentCmd = currentCmd.Parent() } - return "" } func rangeCommands(cmd *Command, callback func(subCmd *Command)) {