fix: ✨ "saner" default for mv#6904
Conversation
fixes nushell#6747 As highlighted in the issue, the default behavior of nu currently is to overwrite the destination file without notice. This is not a "standard" expectation users that want this behavior can create a dedicated alias.
|
Thank you! Looks good to me, I agree that this is much safer+saner behaviour than before. Just going to discuss with the rest of the team before merging. If you have time, would you mind documenting this breaking change in the blog post/release notes for the upcoming v0.71 release? nushell/nushell.github.io#647 |
|
I think we generally like this change but it might be good to add some more tests. @sholderbach had some ideas/requests for testing, @sholderbach do you mind elaborating here? |
|
I just had a thought… maybe not in this PR, but do you think you could add a similar flag for |
|
Nice! @rgwood , yes I can PR the change in the 0.71 release branch, I guess this should be listed in "breaking changes" ? |
This sound like something I can handle! Can you open a dedicated issue ? |
|
I like the change and being more defensive is definitely a good default. GNU coreutils The only question for testing I would have, are we safely prohibiting overwriting non-empty directories after this change? Generally I think in this case for testing it is more important that we test, that we don't cause unintended data loss for the users. I think for files you got us covered. |
|
Nice! |
|
After trying to come up with a new test I'm actually unsure what you meant Sholder? |
|
@melMass you are correct, all other cases I was wondering about (moving a folder on a file etc.) are covered by tests and protected. |
@sholderbach I usually leave that out to better PR people 😅 as english is not my main language, but I drafted it here: |
|
Thanks! Looks perfectly understandable! and people on the internet will be happy to correct any mistakes :P |
I'm a bit confused by this PR. UNIX and Linux behavior has always been for commands such as |
|
Every zsh guide I've seen tells you to turn the NOCLOBBER setting on (which is the equivalent to this) so if that isn't demand, I don't know what is. |
|
For people who've been using Unix/Linux for a long time, this is very unexpected behavior. There is another argument against this default: for people whose jobs require them to use command-line interfaces in critical production contexts, it is important that they do NOT get accustomed to As @sholderbach mentioned above, I think we really want a config option controlling this, since it's a bit awkward in Nushell currently to override a default while retaining control over the rest of the command, i.e. there's no way to do the equivalent of def mv(**kwargs):
stdlib.mv(force=True, **kwargs) |
|
Well, |
|
Also we should bring
I didn't quite follow what you were saying here. |
|
Y'know, this: |
* Release notes for nushell 0.71 Please add your important new features and breaking changes to the release notes by commiting to/opening a PR against the `release-notes-0.71` branch! Thanks for helping out! * add right prompt release notes (nushell#650) * add right prompt release notes * add a comparison image * docs: documents the changes from nushell#6904 (nushell#653) * docs: document changes from nushell#7007 (nushell#659) Co-authored-by: David Matos <david@track32.nl> * Update breaking changes * Breaking change in `format filesize` * Stubs for themes of the release Listed some important improvements that might be worth telling the user about. * mention Reilly's changes for this release * Update 2022-11-08-nushell-0.71.md (nushell#664) * finish up blog post Co-authored-by: nibon7 <nibon7@163.com> Co-authored-by: Mel Massadian <melmassadian@gmail.com> Co-authored-by: David Matos <dmatos2012@users.noreply.github.com> Co-authored-by: David Matos <david@track32.nl> Co-authored-by: Reilly Wood <26268125+rgwood@users.noreply.github.com> Co-authored-by: Jakub Žádník <kubouch@gmail.com> Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>



Description
fixes #6747
As highlighted in the issue, the default behavior of nu currently
is to overwrite the destination file without notice.
This is not a "standard" expectation users that want this behavior
can create a dedicated alias.
Tests
Make sure you've done the following:
Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.Make sure you've run and fixed any issues with these commands:
cargo fmt --all -- --checkto check standard code formatting (cargo fmt --allapplies these changes)cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectto check that you're using the standard code stylecargo test --workspace --features=extrato check that all the tests passDocumentation
Yes, see nushell/nushell.github.io/pull/648