fix: 不使用环境变量获取shell

This commit is contained in:
Akizon77
2025-05-25 13:58:23 +08:00
parent 4cd8626d35
commit 26b54ac85d

View File

@@ -13,10 +13,8 @@ import (
)
func newTerminalImpl() (*terminalImpl, error) {
// 优先获取用户默认 shell
shell := os.Getenv("SHELL")
if shell == "" {
// 如果 SHELL 环境变量为空,尝试从 /etc/passwd 获取
shell := ""
// 从 /etc/passwd 获取
user, err := os.UserHomeDir() // 当前用户
if err == nil {
passwd, err := os.ReadFile("/etc/passwd")
@@ -32,7 +30,6 @@ func newTerminalImpl() (*terminalImpl, error) {
}
}
}
}
// 验证 shell 是否可用
if shell != "" {