| 4647 | } |
| 4648 | |
| 4649 | int cbm_remove_claude_hooks(const char *settings_path) { |
| 4650 | char command[CLI_BUF_8K]; |
| 4651 | char previous_command[CLI_BUF_8K]; |
| 4652 | char released_command[CLI_BUF_8K]; |
| 4653 | char previous_legacy_command[CLI_BUF_8K]; |
| 4654 | char released_legacy_command[CLI_BUF_8K]; |
| 4655 | if (cbm_resolve_hook_command(CMM_HOOK_GATE_SCRIPT, command, sizeof(command)) != CLI_OK || |
| 4656 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT, previous_command, |
| 4657 | sizeof(previous_command)) != CLI_OK || |
| 4658 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT, released_command, |
| 4659 | sizeof(released_command)) != CLI_OK || |
| 4660 | cbm_resolve_previous_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, previous_legacy_command, |
| 4661 | sizeof(previous_legacy_command)) != CLI_OK || |
| 4662 | cbm_resolve_released_hook_command(CMM_HOOK_GATE_SCRIPT_LEGACY, released_legacy_command, |
| 4663 | sizeof(released_legacy_command)) != CLI_OK) { |
| 4664 | return CLI_ERR; |
| 4665 | } |
| 4666 | const char *const old_commands[] = {released_command, previous_command, released_legacy_command, |
| 4667 | previous_legacy_command, NULL}; |
| 4668 | int search_result = remove_hooks_json((hooks_remove_args_t){ |
| 4669 | .settings_path = settings_path, |
| 4670 | .hook_event = "PreToolUse", |
| 4671 | .matcher_str = CMM_HOOK_SEARCH_MATCHER, |
| 4672 | .old_matchers = cmm_claude_old_matchers, |
| 4673 | .old_commands = old_commands, |
| 4674 | .match_command_exact = command, |
| 4675 | }); |
| 4676 | int read_result = remove_hooks_json((hooks_remove_args_t){ |
| 4677 | .settings_path = settings_path, |
| 4678 | .hook_event = "PostToolUse", |
| 4679 | .matcher_str = CMM_HOOK_READ_MATCHER, |
| 4680 | .old_commands = old_commands, |
| 4681 | .match_command_exact = command, |
| 4682 | }); |
| 4683 | return search_result == CLI_OK && read_result == CLI_OK ? CLI_OK : CLI_ERR; |
| 4684 | } |
| 4685 | |
| 4686 | /* Encode one shell word without permitting expansion or command substitution. |
| 4687 | * POSIX single-quoted strings represent an apostrophe as: '\'' */ |
no test coverage detected