Repository navigation
mkdir: don't interrupt when error happened - #18195
Merged
Merged
Conversation
WindSoilder
force-pushed
the
push-zrotxpvlnnzr
branch
2 times, most recently
from
May 13, 2026 08:55
2d01d6d to
a0374b9
Compare
WindSoilder
force-pushed
the
push-zrotxpvlnnzr
branch
from
May 13, 2026 09:07
a0374b9 to
9daab72
Compare
WindSoilder
added a commit
that referenced
this pull request
May 15, 2026
…error happened (#18202) ## Description As title, this pr going to make `rm` works consistently with `mkdir`, which is changed in #18195 To implement this, I need to change early return logic on error case, for any lines returns an Err early, it invokes `collect_rm_result` closure instead, which pushes result to `verbose_out` if `verbose` is set, and may set `first_error` variable if rm results to error. Finally instead of returning `Pipeline::empty`, it may return: - Pipeline::value(Value::list(verbose_out)) if verbose is set - Error if verbose is not set and there is an error - Pipeline::empty ## User-facing changes (Release notes) ### `rm -v` returns structured data ``` > rm -v z a c ╭───┬────────┬─────────┬───────────╮ │ # │ path │ deleted │ error │ ├───┼────────┼─────────┼───────────┤ │ 0 │ /tmp/z │ false │ Not found │ │ 1 │ /tmp/c │ false │ Not found │ │ 2 │ /tmp/a │ true │ │ ╰───┴────────┴─────────┴───────────╯ ``` ### `rm` removes other files even if there is an error in the middle ``` > touch a > rm z c a Error: nu::shell::io::not_found × Not found ╭─[repl_entry #7:1:6] 1 │ rm z c a · ┬ · ╰── Not found ╰──── help: '/tmp/c' does not exist Error: nu:🐚:io::not_found × Not found ╭─[repl_entry #7:1:4] 1 │ rm z c a · ┬ · ╰── Not found ╰──── help: '/tmp/z' does not exist > 'a' | path exists false ``` ## Additional notes - related: #15413
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.
Description
This pr makes mkdir handle all non-error conditions through completion.
User-facing changes (Release notes)
mkdir will try to create all directories, even if errors happened in the middle
Also noted that the errors are pointed to correct span. Previously it points to
crates/nu-command/src/filesystem/umkdir.rs:95:48, which is not user friendly.Additional notes
related: #15413