@@ -3959,11 +3959,11 @@ static int cbm_remove_owned_hook_script(const char *path, const char *expected_c
39593959 * match a current or released installer-owned script. Modified/foreign files
39603960 * at the reserved path are preserved. POSIX keeps the extensionless name,
39613961 * where legacy == current, so no separate cleanup is needed there. */
3962+ #ifdef _WIN32
39623963static int cbm_remove_owned_legacy_hook_script (const char * hooks_dir , const char * legacy_name ,
39633964 const char * current_script ,
39643965 const char * const * released_scripts ,
39653966 size_t released_script_count ) {
3966- #ifdef _WIN32
39673967 if (!hooks_dir || !legacy_name || !current_script ) {
39683968 return CLI_ERR ;
39693969 }
@@ -3975,15 +3975,8 @@ static int cbm_remove_owned_legacy_hook_script(const char *hooks_dir, const char
39753975 int result = cbm_text_remove_owned_document_any (legacy_path , current_script , released_scripts ,
39763976 released_script_count );
39773977 return result < CLI_OK ? CLI_ERR : CLI_OK ;
3978- #else
3979- (void )hooks_dir ;
3980- (void )legacy_name ;
3981- (void )current_script ;
3982- (void )released_scripts ;
3983- (void )released_script_count ;
3984- return CLI_OK ;
3985- #endif
39863978}
3979+ #endif
39873980
39883981bool cbm_install_hook_gate_script (const char * home , const char * binary_path ) {
39893982 if (!home || !binary_path ) {
@@ -4021,10 +4014,12 @@ bool cbm_install_hook_gate_script(const char *home, const char *binary_path) {
40214014 sizeof (released_script )) == CLI_OK
40224015 ? 1U
40234016 : 0U ;
4017+ #ifdef _WIN32
40244018 if (cbm_remove_owned_legacy_hook_script (hooks_dir , CMM_HOOK_GATE_SCRIPT_LEGACY , script , legacy ,
40254019 legacy_count ) != CLI_OK ) {
40264020 return false;
40274021 }
4022+ #endif
40284023 return cbm_write_owned_hook_script_with_legacy (script_path , script , legacy , legacy_count );
40294024}
40304025
@@ -4067,10 +4062,12 @@ static bool cbm_install_session_reminder_script(const char *home, const char *bi
40674062 return false;
40684063 }
40694064 const char * const legacy [] = {cmm_released_session_script };
4065+ #ifdef _WIN32
40704066 if (cbm_remove_owned_legacy_hook_script (hooks_dir , CMM_SESSION_REMINDER_SCRIPT_LEGACY , script ,
40714067 legacy , 1U ) != CLI_OK ) {
40724068 return false;
40734069 }
4070+ #endif
40744071 return cbm_write_owned_hook_script_with_legacy (script_path , script , legacy , 1U );
40754072}
40764073
@@ -4259,10 +4256,12 @@ static bool cbm_install_subagent_reminder_script(const char *home, const char *b
42594256 return false;
42604257 }
42614258 const char * const legacy [] = {cmm_released_subagent_script };
4259+ #ifdef _WIN32
42624260 if (cbm_remove_owned_legacy_hook_script (hooks_dir , CMM_SUBAGENT_REMINDER_SCRIPT_LEGACY , script ,
42634261 legacy , 1U ) != CLI_OK ) {
42644262 return false;
42654263 }
4264+ #endif
42664265 return cbm_write_owned_hook_script_with_legacy (script_path , script , legacy , 1U );
42674266}
42684267
@@ -7839,6 +7838,7 @@ static void uninstall_claude_code(const char *home, bool dry_run) {
78397838 record_agent_config_error (true, "Claude Code" , "hook_script_uninstall" ,
78407839 script_path_valid ? script_path : owned_scripts [i ].name );
78417840 }
7841+ #ifdef _WIN32
78427842 if (!hooks_dir_valid ||
78437843 cbm_remove_owned_legacy_hook_script (
78447844 hooks_dir , owned_scripts [i ].legacy_name , owned_scripts [i ].current ,
@@ -7852,6 +7852,7 @@ static void uninstall_claude_code(const char *home, bool dry_run) {
78527852 ? legacy_path
78537853 : owned_scripts [i ].legacy_name );
78547854 }
7855+ #endif
78557856 }
78567857 }
78577858 printf (" removed PreToolUse + SessionStart + SubagentStart hooks\n" );
0 commit comments