From 5bffead6654c105d2cd35af5c5c5b1cea4593411 Mon Sep 17 00:00:00 2001 From: Imran Solanki Date: Wed, 21 Aug 2024 14:48:44 +0530 Subject: [PATCH] fix: /bin/zsh env variable to retrieve current active shell --- examples_test.go | 2 +- help.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples_test.go b/examples_test.go index 8802d54907..28a34e4a96 100644 --- a/examples_test.go +++ b/examples_test.go @@ -405,7 +405,7 @@ func ExampleCommand_Run_shellComplete_zsh() { // Simulate a zsh environment and command line arguments os.Args = []string{"greet", "--generate-shell-completion"} - os.Setenv("SHELL", "/usr/bin/zsh") + os.Setenv("0", "/usr/bin/zsh") _ = cmd.Run(context.Background(), os.Args) // Output: diff --git a/help.go b/help.go index f4fc09ee6c..d3923ace04 100644 --- a/help.go +++ b/help.go @@ -159,7 +159,7 @@ func printCommandSuggestions(commands []*Command, writer io.Writer) { if command.Hidden { continue } - if strings.HasSuffix(os.Getenv("SHELL"), "zsh") { + if strings.HasSuffix(os.Getenv("0"), "zsh") { _, _ = fmt.Fprintf(writer, "%s:%s\n", command.Name, command.Usage) } else { _, _ = fmt.Fprintf(writer, "%s\n", command.Name)