| 852 | /* ── Shell RC detection ───────────────────────────────────────── */ |
| 853 | |
| 854 | const char *cbm_detect_shell_rc(const char *home_dir) { |
| 855 | static char buf[CLI_BUF_512]; |
| 856 | if (!home_dir || !home_dir[0]) { |
| 857 | return ""; |
| 858 | } |
| 859 | |
| 860 | char shell_buf[CLI_BUF_256]; |
| 861 | const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), ""); |
| 862 | if (!shell) { |
| 863 | shell = ""; |
| 864 | } |
| 865 | |
| 866 | if (strstr(shell, "/zsh")) { |
| 867 | snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir); |
| 868 | return buf; |
| 869 | } |
| 870 | if (strstr(shell, "/bash")) { |
| 871 | /* Prefer .bashrc, fall back to .bash_profile */ |
| 872 | snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir); |
| 873 | struct stat st; |
| 874 | if (stat(buf, &st) == 0) { |
| 875 | return buf; |
| 876 | } |
| 877 | snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir); |
| 878 | return buf; |
| 879 | } |
| 880 | if (strstr(shell, "/fish")) { |
| 881 | snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir); |
| 882 | return buf; |
| 883 | } |
| 884 | |
| 885 | /* Default to .profile */ |
| 886 | snprintf(buf, sizeof(buf), "%s/.profile", home_dir); |
| 887 | return buf; |
| 888 | } |
| 889 | |
| 890 | /* ── CLI binary detection ─────────────────────────────────────── */ |
| 891 |
no test coverage detected