Skip to content

rm: returns structure data when -v is used, and don't interrupt when error happened - #18202

Merged
WindSoilder merged 1 commit into
nushell:mainfrom
WindSoilder:push-wnoumzxwpkmp
May 15, 2026
Merged

WindSoilder merged 1 commit into
nushell:mainfrom
WindSoilder:push-wnoumzxwpkmp

Conversation

@WindSoilder

@WindSoilder WindSoilder commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

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::shell::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

@WindSoilder WindSoilder added the A:commands General additions or changes to commands label May 14, 2026
…s all args even if there is an error in the middle
@WindSoilder
WindSoilder merged commit f95c3d6 into nushell:main May 15, 2026
17 checks passed
@github-actions github-actions Bot added this to the v0.113.0 milestone May 15, 2026
@fdncred fdncred added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:commands General additions or changes to commands notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants