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

Function cbm_detect_shell_rc

src/cli/cli.c:831–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829/* ── Shell RC detection ───────────────────────────────────────── */
830
831const 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

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