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

Function cbm_detect_shell_rc

src/cli/cli.c:876–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874/* ── Shell RC detection ───────────────────────────────────────── */
875
876const char *cbm_detect_shell_rc(const char *home_dir) {
877 static char buf[CLI_BUF_512];
878 if (!home_dir || !home_dir[0]) {
879 return "";
880 }
881
882 char shell_buf[CLI_BUF_256];
883 const char *shell = cbm_safe_getenv("SHELL", shell_buf, sizeof(shell_buf), "");
884 if (!shell) {
885 shell = "";
886 }
887
888 if (strstr(shell, "/zsh")) {
889 snprintf(buf, sizeof(buf), "%s/.zshrc", home_dir);
890 return buf;
891 }
892 if (strstr(shell, "/bash")) {
893 /* Prefer .bashrc, fall back to .bash_profile */
894 snprintf(buf, sizeof(buf), "%s/.bashrc", home_dir);
895 struct stat st;
896 if (stat(buf, &st) == 0) {
897 return buf;
898 }
899 snprintf(buf, sizeof(buf), "%s/.bash_profile", home_dir);
900 return buf;
901 }
902 if (strstr(shell, "/fish")) {
903 snprintf(buf, sizeof(buf), "%s/.config/fish/config.fish", home_dir);
904 return buf;
905 }
906
907 /* Default to .profile */
908 snprintf(buf, sizeof(buf), "%s/.profile", home_dir);
909 return buf;
910}
911
912/* ── CLI binary detection ─────────────────────────────────────── */
913

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