getShellConfigPath retorna o caminho do arquivo de configuração do shell
(shell string)
| 252 | |
| 253 | // getShellConfigPath retorna o caminho do arquivo de configuração do shell |
| 254 | func (e *CommandExecutor) getShellConfigPath(shell string) string { |
| 255 | shellName := filepath.Base(shell) |
| 256 | homeDir, err := os.UserHomeDir() |
| 257 | if err != nil { |
| 258 | return "" |
| 259 | } |
| 260 | |
| 261 | switch shellName { |
| 262 | case "bash": |
| 263 | return filepath.Join(homeDir, ".bashrc") |
| 264 | case "zsh": |
| 265 | return filepath.Join(homeDir, ".zshrc") |
| 266 | case "fish": |
| 267 | return filepath.Join(homeDir, ".config", "fish", "config.fish") |
| 268 | default: |
| 269 | return "" |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | // validateShellConfig checks that a shell config file is safe to source. |
| 274 | // It rejects symlinks (which could point to malicious files) and |