| 874 | /* ── Shell RC detection ───────────────────────────────────────── */ |
| 875 | |
| 876 | const char *cbm_detect_shell_rc(const char *home_dir) { |
| 877 | static char buf[CLI_BUF_512]; |
| 878 | if (!home_dir || !home_dir[0]) { |
| 879 | return ""; |
| 880 | } |
| 881 | |
| 882 | char shell_buf[CLI_BUF_256]; |
| 883 | const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), ""); |
| 884 | if (!shell) { |
| 885 | shell = ""; |
| 886 | } |
| 887 | |
| 888 | if (strstr(shell, "/zsh")) { |
| 889 | snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir); |
| 890 | return buf; |
| 891 | } |
| 892 | if (strstr(shell, "/bash")) { |
| 893 | /* Prefer .bashrc, fall back to .bash_profile */ |
| 894 | snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir); |
| 895 | struct stat st; |
| 896 | if (stat(buf, &st) == 0) { |
| 897 | return buf; |
| 898 | } |
| 899 | snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir); |
| 900 | return buf; |
| 901 | } |
| 902 | if (strstr(shell, "/fish")) { |
| 903 | snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir); |
| 904 | return buf; |
| 905 | } |
| 906 | |
| 907 | /* Default to .profile */ |
| 908 | snprintf(buf, sizeof(buf), "%s/.profile", home_dir); |
| 909 | return buf; |
| 910 | } |
| 911 | |
| 912 | /* ── CLI binary detection ─────────────────────────────────────── */ |
| 913 |
no test coverage detected