Fix "mv allows moving a directory into itself"#2619
Merged
sophiajt merged 22 commits intonushell:mainfrom Oct 1, 2020
Merged
Conversation
Now when you a use rm -f there will be no error message, even if the file doesnt actually exist
Contributor
|
Looks good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2612
Old behaviour allowed this, and just deleted the file
mkdir amkdir a/bmv a a/bNew behaviour
mkdir amkdir a/bmv a a/bmv a a/b^ cannot move "a" to itselfThere was also a second problem related to the first, in other shells, if i try mv with more than one source, it just ignores the destination file. So that one file will not break the whole process. I decided to add this behavior. It now works like this.
mkdir foo bar fizzmv * fizzls fizzfoo barI have two questions now
1 - Should i give some type of warning that some files will not be moved(just like the classic mv command), and if so how could i give this warning without stopping the process?
2 - I decided to make the "sources" variable mutable and use a filter to remove the error files, i could also do this checking in the for loop that moves the files(Line 501), but i thought this way would make the code less readable given that there would be a piece of code that does two different things at the same time. Was that the best decision?