| 829 | /* ── Shell RC detection ───────────────────────────────────────── */ |
| 830 | |
| 831 | const char *cbm_detect_shell_rc(const char *home_dir) { |
| 832 | static char buf[CLI_BUF_512]; |
| 833 | if (!home_dir || !home_dir[0]) { |
| 834 | return ""; |
| 835 | } |
| 836 | |
| 837 | char shell_buf[CLI_BUF_256]; |
| 838 | const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), ""); |
| 839 | if (!shell) { |
| 840 | shell = ""; |
| 841 | } |
| 842 | |
| 843 | if (strstr(shell, "/zsh")) { |
| 844 | snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir); |
| 845 | return buf; |
| 846 | } |
| 847 | if (strstr(shell, "/bash")) { |
| 848 | /* Prefer .bashrc, fall back to .bash_profile */ |
| 849 | snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir); |
| 850 | struct stat st; |
| 851 | if (stat(buf, &st) == 0) { |
| 852 | return buf; |
| 853 | } |
| 854 | snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir); |
| 855 | return buf; |
| 856 | } |
| 857 | if (strstr(shell, "/fish")) { |
| 858 | snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir); |
| 859 | return buf; |
| 860 | } |
| 861 | |
| 862 | /* Default to .profile */ |
| 863 | snprintf(buf, sizeof(buf), "%s/.profile", home_dir); |
| 864 | return buf; |
| 865 | } |
| 866 | |
| 867 | /* ── CLI binary detection ─────────────────────────────────────── */ |
| 868 |
no test coverage detected