| 1 | package shell |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | ) |
| 6 | |
| 7 | // CurrentUserShell returns the current user's shell. |
| 8 | func CurrentUserShell() (string, bool) { |
| 9 | // If the SHELL environment variable is set, use it. |
| 10 | if shell, ok := os.LookupEnv("SHELL"); ok { |
| 11 | return shell, true |
| 12 | } |
| 13 | |
| 14 | // If the ComSpec environment variable is set, use it. |
| 15 | if comSpec, ok := os.LookupEnv("ComSpec"); ok { |
| 16 | return comSpec, true |
| 17 | } |
| 18 | |
| 19 | // Fallback to the default shell. |
| 20 | return DefaultShell(), false |
| 21 | } |