MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_detect_shell_rc

Function cbm_detect_shell_rc

src/cli/cli.c:825–859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823/* ── Shell RC detection ───────────────────────────────────────── */
824
825const 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

Callers 2

cbm_cmd_installFunction · 0.85
test_cli.cFile · 0.85

Calls 2

cbm_safe_getenvFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected