| 1070 | /* ── Shell RC detection ───────────────────────────────────────── */ |
| 1071 | |
| 1072 | const char *cbm_detect_shell_rc(const char *home_dir) { |
| 1073 | static char buf[CLI_BUF_512]; |
| 1074 | if (!home_dir || !home_dir[0]) { |
| 1075 | return ""; |
| 1076 | } |
| 1077 | |
| 1078 | char shell_buf[CLI_BUF_256]; |
| 1079 | const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), ""); |
| 1080 | if (!shell) { |
| 1081 | shell = ""; |
| 1082 | } |
| 1083 | |
| 1084 | if (strstr(shell, "/zsh")) { |
| 1085 | snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir); |
| 1086 | return buf; |
| 1087 | } |
| 1088 | if (strstr(shell, "/bash")) { |
| 1089 | /* Prefer .bashrc, fall back to .bash_profile */ |
| 1090 | snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir); |
| 1091 | struct stat st; |
| 1092 | if (stat(buf, &st) == 0) { |
| 1093 | return buf; |
| 1094 | } |
| 1095 | snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir); |
| 1096 | return buf; |
| 1097 | } |
| 1098 | if (strstr(shell, "/fish")) { |
| 1099 | snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir); |
| 1100 | return buf; |
| 1101 | } |
| 1102 | |
| 1103 | /* Default to .profile */ |
| 1104 | snprintf(buf, sizeof(buf), "%s/.profile", home_dir); |
| 1105 | return buf; |
| 1106 | } |
| 1107 | |
| 1108 | /* ── CLI binary detection ─────────────────────────────────────── */ |
| 1109 |
no test coverage detected