-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
rm: Added descend messages for interactive mode Fixes #3817 #3931
Conversation
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.
Cool! Looks like WalkDir
is becoming a bit of a hassle to work around, but this looks like a good way to do this for now. Could you add a test to check that we don't regress?
it would be nice if you could make GNU's test rm3.sh & rm5.sh work as they are also testing the bash util/run-gnu-test.sh tests/rm/rm3.sh |
For making a regression test do you guys know/have an example test where you interact with the child process stdout and stdin? |
Just looked at rm3.sh and it seems to only be falling because our prompts aren't as descriptive as gnu. |
Would the https://github.com/uutils/coreutils/blob/main/tests/by-util/test_cp.rs#L199-L208
Yeah a separate PR makes sense I think. |
Unfortunately, that won't work for this use case where the command waits for responses and does something different depending on it. I am currently looking at just using a bare Child and then reading and writing to its stdin and stdout... but that is proving challenging. |
Okay, I have created a very basic test for checking directory descending. |
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.
I like it! We can merge this once the CI succeeds and my nits below are addressed.
There seems to be some trouble on macos and windows:
|
So, the reason it was hanging up is because of CRLF vs LF when I was inserting it into stdin. I also had to remake the test because of something I noticed with WalkDir that depending on the system the order in which it traverses can differ. Everything seems to be working now |
|
||
let mut child: Child = scene.ucmd().arg("-ri").arg("a").run_no_wait(); | ||
|
||
let mut child_stdin = child.stdin.take().unwrap(); |
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 document why it is needed
if options.interactive == InteractiveMode::Always { | ||
for not_descend in ¬_descended { | ||
if entry.path().starts_with(not_descend) { | ||
continue 'outer; |
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 explaining why we do that here
} else { | ||
not_descended.push(entry.path().to_path_buf()); | ||
} | ||
} else { |
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 here. it is starting to be quite complex with the various if and else
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.
misses some comments
Co-authored-by: Terts Diepraam <[email protected]>
Nice |
Added descend functionality for rm's interactive mode
Setup
Current
GNU
After Commit (Using the same answers as before)
After Commit (Don't descend into a/b)