Skip to content

Commit 30daf72

Browse files
committed
fixup
1 parent f9ba2e9 commit 30daf72

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

completion/all.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ const (
2727
ShellPowershell string = "powershell"
2828
)
2929

30-
func ShellByName(shell, programName string) Shell {
30+
func ShellByName(shell, programName string) (Shell, error) {
3131
switch shell {
3232
case ShellBash:
33-
return Bash(runtime.GOOS, programName)
33+
return Bash(runtime.GOOS, programName), nil
3434
case ShellFish:
35-
return Fish(runtime.GOOS, programName)
35+
return Fish(runtime.GOOS, programName), nil
3636
case ShellZsh:
37-
return Zsh(runtime.GOOS, programName)
37+
return Zsh(runtime.GOOS, programName), nil
3838
case ShellPowershell:
39-
return Powershell(runtime.GOOS, programName)
39+
return Powershell(runtime.GOOS, programName), nil
4040
default:
41-
return nil
41+
return nil, fmt.Errorf("unsupported shell %q", shell)
4242
}
4343
}
4444

@@ -49,7 +49,7 @@ func ShellOptions(choice *string) *serpent.Enum {
4949
func DetectUserShell(programName string) (Shell, error) {
5050
// Attempt to get the SHELL environment variable first
5151
if shell := os.Getenv("SHELL"); shell != "" {
52-
return ShellByName(filepath.Base(shell), ""), nil
52+
return ShellByName(filepath.Base(shell), "")
5353
}
5454

5555
// Fallback: Look up the current user and parse /etc/passwd
@@ -69,7 +69,7 @@ func DetectUserShell(programName string) (Shell, error) {
6969
if strings.HasPrefix(line, currentUser.Username+":") {
7070
parts := strings.Split(line, ":")
7171
if len(parts) > 6 {
72-
return ShellByName(filepath.Base(parts[6]), programName), nil // The shell is typically the 7th field
72+
return ShellByName(filepath.Base(parts[6]), programName) // The shell is typically the 7th field
7373
}
7474
}
7575
}

0 commit comments

Comments
 (0)