Skip to content

Conversation

@GomesGoncalo
Copy link

Detect symlinks in prompt_file() using fs::symlink_metadata() and handle them differently:

  • InteractiveMode::Always should still prompt with "remove symbolic link ...?".
  • For all other interactive modes, do not follow the symlink target or use the target's permissions to decide a write-protected prompt.

Adds a unit test test_symlink_not_write_protected_prompt to verify that a symlink to a read-only file is not treated as a write-protected regular file.

Closes #10222

@GomesGoncalo GomesGoncalo force-pushed the goncalo.gomes/rm-symlink-behaviour branch 2 times, most recently from f3f691e to aad33db Compare January 14, 2026 13:30
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 14, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 4.56%

Comparing GomesGoncalo:goncalo.gomes/rm-symlink-behaviour (c2a1956) with main (2c75e71)

Summary

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 279 untouched benchmarks
⏩ 38 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory sort_ascii_utf8_locale 6.7 MB 6.2 MB +7.93%
Simulation rm_multiple_files 2.2 ms 2.4 ms -4.56%
Memory du_deep_tree[(100, 3)] 157.9 KB 147.1 KB +7.35%

Footnotes

  1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@GomesGoncalo
Copy link
Author

GomesGoncalo commented Jan 14, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 4.57%

Comparing GomesGoncalo:goncalo.gomes/rm-symlink-behaviour (aad33db) with main (fd9157a)

Summary

❌ 1 regressed benchmark ✅ 140 untouched benchmarks ⏩ 38 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation rm_multiple_files 2.2 ms 2.4 ms -4.57%

Footnotes

1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, [click here and archive them to remove them from the performance reports](https://codspeed.io/uutils/coreutils/branches/GomesGoncalo%3Agoncalo.gomes%2Frm-symlink-behaviour?sectionId=benchmark-comparison-section-baseline-result-skipped&utm_source=github&utm_medium=comment&utm_content=archive). [↩](#user-content-fnref-skipped-65dfc430c8cce12c4551dab4f7d2efc4)
image

looks like entirely related to querying symlink metadata, I tried reversing the logic but found the branch needs to be always taken to keep the functionality

@GomesGoncalo GomesGoncalo force-pushed the goncalo.gomes/rm-symlink-behaviour branch from aad33db to 6ef66b5 Compare January 15, 2026 10:31
Detect symlinks in prompt_file() using fs::symlink_metadata() and handle them differently:
- InteractiveMode::Always should still prompt with "remove symbolic link ...?".
- For all other interactive modes, do not follow the symlink target or use the target's permissions to decide a write-protected prompt.

Adds a unit test test_symlink_not_write_protected_prompt to verify that a symlink to a read-only file is not treated as a write-protected regular file.
@GomesGoncalo GomesGoncalo force-pushed the goncalo.gomes/rm-symlink-behaviour branch from 6ef66b5 to c2a1956 Compare January 15, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rm symlink asks confirmation when its source file is write-protected

2 participants