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

Function cbm_resolve_previous_hook_command

src/cli/cli.c:2597–2612  ·  view source on GitHub ↗

Resolve the exact shell-quoted command form shipped immediately before the * explicit Windows cmd.exe wrapper. It remains an ownership identity only. */

Source from the content-addressed store, hash-verified

2595/* Resolve the exact shell-quoted command form shipped immediately before the
2596 * explicit Windows cmd.exe wrapper. It remains an ownership identity only. */
2597static int cbm_resolve_previous_hook_command(const char *script_name, char *out, size_t out_sz) {
2598 if (!cbm_hook_script_name_safe(script_name) || !out || out_sz == 0U) {
2599 return CLI_ERR;
2600 }
2601 char env_buf[CLI_BUF_1K];
2602 const char *env = cbm_safe_getenv("CLAUDE_CONFIG_DIR", env_buf, sizeof(env_buf), NULL);
2603 if (env && env[0]) {
2604 char path[CLI_BUF_1K];
2605 int written = snprintf(path, sizeof(path), "%s/hooks/%s", env, script_name);
2606 return written > 0 && (size_t)written < sizeof(path)
2607 ? cbm_shell_quote_word(path, out, out_sz)
2608 : CLI_ERR;
2609 }
2610 int written = snprintf(out, out_sz, "\"$HOME/.claude/hooks/%s\"", script_name);
2611 return written > 0 && (size_t)written < out_sz ? CLI_OK : CLI_ERR;
2612}
2613
2614/* Resolve only the exact command form shipped before hook paths were shell
2615 * quoted. This is an ownership identity for upgrade/uninstall, never a command

Calls 3

cbm_safe_getenvFunction · 0.85
cbm_shell_quote_wordFunction · 0.85

Tested by

no test coverage detected