Skip to content

Commit bcc6869

Browse files
Merge pull request #1970 from asahasrabuddhe/backport-issue-1884
[Backport] Fix: Use $0 env var to correctly retrieve the current active shell
2 parents 9114559 + e3ff573 commit bcc6869

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func ExampleApp_Run_bashComplete() {
369369
func ExampleApp_Run_zshComplete() {
370370
// set args for examples sake
371371
os.Args = []string{"greet", "--generate-bash-completion"}
372-
_ = os.Setenv("SHELL", "/usr/bin/zsh")
372+
_ = os.Setenv("0", "/usr/bin/zsh")
373373

374374
app := NewApp()
375375
app.Name = "greet"

help.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func printCommandSuggestions(commands []*Command, writer io.Writer) {
150150
if command.Hidden {
151151
continue
152152
}
153-
if strings.HasSuffix(os.Getenv("SHELL"), "zsh") {
153+
if strings.HasSuffix(os.Getenv("0"), "zsh") {
154154
for _, name := range command.Names() {
155155
_, _ = fmt.Fprintf(writer, "%s:%s\n", name, command.Usage)
156156
}

0 commit comments

Comments
 (0)