| 4668 | } |
| 4669 | |
| 4670 | int cbm_remove_claude_hooks(const char *settings_path) { |
| 4671 | char command[CLI_BUF_8K]; |
| 4672 | char previous_command[CLI_BUF_8K]; |
| 4673 | char released_command[CLI_BUF_8K]; |
| 4674 | char previous_legacy_command[CLI_BUF_8K]; |
| 4675 | char released_legacy_command[CLI_BUF_8K]; |
| 4676 | if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 4677 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command, |
| 4678 | sizeof(previous_command)) != CLI_OK || |
| 4679 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command, |
| 4680 | sizeof(released_command)) != CLI_OK || |
| 4681 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command, |
| 4682 | sizeof(previous_legacy_command)) != CLI_OK || |
| 4683 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command, |
| 4684 | sizeof(released_legacy_command)) != CLI_OK) { |
| 4685 | return CLI_ERR; |
| 4686 | } |
| 4687 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 4688 | previous_legacy_command, NULL}; |
| 4689 | int search_result = remove_hooks_json((hooks_remove_args_t){ |
| 4690 | .settings_path = settings_path, |
| 4691 | .hook_event = "PreToolUse", |
| 4692 | .matcher_str = CMM_HOOK_SEARCH_MATCHER, |
| 4693 | .old_matchers = cmm_claude_old_matchers, |
| 4694 | .old_commands = old_commands, |
| 4695 | .match_command_exact = command, |
| 4696 | }); |
| 4697 | int read_result = remove_hooks_json((hooks_remove_args_t){ |
| 4698 | .settings_path = settings_path, |
| 4699 | .hook_event = "PostToolUse", |
| 4700 | .matcher_str = CMM_HOOK_READ_MATCHER, |
| 4701 | .old_commands = old_commands, |
| 4702 | .match_command_exact = command, |
| 4703 | }); |
| 4704 | return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR; |
| 4705 | } |
| 4706 | |
| 4707 | /* Encode one shell word without permitting expansion or command substitution. |
| 4708 | * POSIX single-quoted strings represent an apostrophe as: '\'' */ |
no test coverage detected