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