| 196 | /* ── Shell RC detection ───────────────────────────────────────── */ |
| 197 | |
| 198 | const char *cbm_detect_shell_rc(const char *home_dir) { |
| 199 | static char buf[CLI_BUF_512]; |
| 200 | if (!home_dir || !home_dir[0]) { |
| 201 | return ""; |
| 202 | } |
| 203 | |
| 204 | char shell_buf[CLI_BUF_256]; |
| 205 | const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), ""); |
| 206 | if (!shell) { |
| 207 | shell = ""; |
| 208 | } |
| 209 | |
| 210 | if (strstr(shell, "/zsh")) { |
| 211 | snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir); |
| 212 | return buf; |
| 213 | } |
| 214 | if (strstr(shell, "/bash")) { |
| 215 | /* Prefer .bashrc, fall back to .bash_profile */ |
| 216 | snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir); |
| 217 | struct stat st; |
| 218 | if (stat(buf, &st) == 0) { |
| 219 | return buf; |
| 220 | } |
| 221 | snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir); |
| 222 | return buf; |
| 223 | } |
| 224 | if (strstr(shell, "/fish")) { |
| 225 | snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir); |
| 226 | return buf; |
| 227 | } |
| 228 | |
| 229 | /* Default to .profile */ |
| 230 | snprintf(buf, sizeof(buf), "%s/.profile", home_dir); |
| 231 | return buf; |
| 232 | } |
| 233 | |
| 234 | /* ── CLI binary detection ─────────────────────────────────────── */ |
| 235 |
no test coverage detected