-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
rm: fix for -rf ./ and variants silently delete current directory con… #9765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
GNU testsuite comparison: |
|
I was also looking at this issue but saw it was already taken. I think it would be good if you added a regression test too. The test you edited just checks that the the message output is right but not if they do not silently delete the files/directories. also i think you missed 1 case but im not 100% sure |
|
Hi @cerdelen |
|
the tests are okay but shouldn't in the coud in file so xyz/. isnt xyz/../ missing this is what i refered to with |
|
Checks for silent removal added |
|
@cerdelen it's already there at line 860 or I'm missing something? |
|
Oh yes i with the github interface it got cropped out and i didnt see it. My bad! |
|
GNU testsuite comparison: |
|
I'm confused why pipeline failed, I don't see any error message. I see that mac os build fails for other PRs too |
|
I'm not 100% sure. But I think random failure of |
|
@oech3 seems like some issue with concurrency on Mac OS |
|
Ok I think that I have broken pipeline because I didn't add |
|
GNU testsuite comparison: |
| let result = determine_backup_mode(&matches).unwrap(); | ||
|
|
||
| assert_eq!(result, BackupMode::Numbered); | ||
| unsafe { env::remove_var(ENV_VERSION_CONTROL) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment to explain why you have to do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment in the code? No other removals have it, add it to all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it isn't clear to me why this variable has to be removed here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it can affect other tests that are using env, but this is fragile though because if test fails this will not be cleaned up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add this information in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
I don't know why other tests are failing, they don't seem to be related with this PR at all. I'm missing something here @sylvestre ? |
|
yeah, just ignore that :) |
|
GNU testsuite comparison: |
I have added checks for ./ ad ../ as I can see other variants are already covered.
Did I missed any other cases?
I have asked AI (both gemini and gpt) but it seems to provide covered use cases like:
Input
././.
../..
dir/.
dir/..
I'm not sure about preventing removing root like '/' or '//' because I don't have enough courage to check if coreutils will react same as gnu rm