@@ -1942,23 +1942,41 @@ def handle_direct_cli_commands():
19421942
19431943 for path in paths :
19441944 try :
1945+ # For relative paths, resolve them from the user's current working directory (PWD env var)
1946+ # This is needed because the process may start with a different cwd than the user's shell
1947+ if not os .path .isabs (path ):
1948+ user_cwd = os .environ .get ('PWD' , os .getcwd ())
1949+ abs_path = os .path .abspath (os .path .join (user_cwd , path ))
1950+ else :
1951+ abs_path = os .path .abspath (path )
1952+
1953+ if VERBOSE_MODE :
1954+ print (f"[TOGGLE] Input path: { path } " )
1955+ print (f"[TOGGLE] User PWD: { os .environ .get ('PWD' , 'not set' )} " )
1956+ print (f"[TOGGLE] Absolute path: { abs_path } " )
1957+
19451958 # Use lexists() instead of exists() because protected folders (chmod 000)
19461959 # are inaccessible but still exist on the filesystem
1947- if not os .path .lexists (path ):
1960+ if not os .path .lexists (abs_path ):
1961+ if VERBOSE_MODE :
1962+ print (f"[TOGGLE] Path check failed with lexists(): { abs_path } " )
19481963 print_error (f"✗ Path does not exist: { path } " )
19491964 failed_count += 1
19501965 continue
19511966
1967+ if VERBOSE_MODE :
1968+ print (f"[TOGGLE] Path exists, checking protection state..." )
1969+
19521970 # Check current protection state
1953- current_protected_state = cli_handler .is_tamper_proof_enabled (path )
1971+ current_protected_state = cli_handler .is_tamper_proof_enabled (abs_path )
19541972
19551973 # Only toggle if state is different from desired state
19561974 if current_protected_state == toggle_mode :
19571975 skipped_count += 1
19581976 continue
19591977
19601978 # Toggle protection
1961- if cli_handler .toggle_tamper_proof (path , toggle_mode ):
1979+ if cli_handler .toggle_tamper_proof (abs_path , toggle_mode ):
19621980 toggled_paths .append (os .path .basename (path ))
19631981 toggled_count += 1
19641982 else :
0 commit comments