mirror of
https://github.com/wavetermdev/waveterm
synced 2026-04-21 14:37:16 +00:00
40 lines
706 B
Go
40 lines
706 B
Go
//go:build !windows
|
|
|
|
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/wavetermdev/waveterm/pkg/util/shellutil"
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(shellCmd)
|
|
}
|
|
|
|
var shellCmd = &cobra.Command{
|
|
Use: "shell",
|
|
Hidden: true,
|
|
Short: "Print the login shell of this user",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
WriteStdout("%s", shellCmdInner())
|
|
},
|
|
}
|
|
|
|
func shellCmdInner() string {
|
|
if runtime.GOOS == "darwin" {
|
|
return shellutil.GetMacUserShell() + "\n"
|
|
}
|
|
|
|
shell := os.Getenv("SHELL")
|
|
if shell == "" {
|
|
return "/bin/bash\n"
|
|
}
|
|
return strings.TrimSpace(shell) + "\n"
|
|
}
|