Repository navigation
Revert "mkdir errors on already-created dir" - #19008
Conversation
This reverts commit 954e34d.
|
sure it's a breaking change, but... anyway, if that's what has been decided, then sure, I'll make a quick PR 👍 |
|
Agree with the As for the whether the error should be default, it's not a new decision. It's explicitly documented, e.g. here https://www.nushell.sh/book/moving_around.html#creating-a-directory. In REPL it doesn't matter that much, as you can just ignore the error, but in scripts it's quite convenient, as you don't have to wrap it in |
The default mkdir stays -p-like/idempotent (making it error by default was reverted in nushell#19008 as a breaking change). Per the maintainer's suggestion on already exists ("<path>: File exists", matching coreutils) while still creating non-existing targets in the same call. Default behavior unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…#19021) # Description Follow-up to #19003. The default `mkdir` behavior (idempotent, `-p`-like) stays exactly as-is — #19006 tried making it error by default and was reverted in #19008, since people rely on `mkdir foo` to just ensure a directory exists (and `^mkdir -p` doesn't error either). Per @fdncred's suggestion in the thread, this instead adds an **opt-in** flag. With `--fail-if-exists`, `mkdir` errors on a target that already exists (message `<path>: File exists`, matching coreutils), while still creating any non-existing targets passed in the same call. Without the flag, nothing changes. The `--verbose` `created: true` half of the issue was already fixed in #19017, so this covers the remaining piece. # User-Facing Changes New opt-in switch: `mkdir --fail-if-exists <dir>` (short: none) errors if the directory already exists instead of silently succeeding. Default `mkdir` is unchanged. # Tests + Formatting Added `commands::umkdir` tests: errors on an existing dir with the flag, still creates new dirs with the flag, and `-v --fail-if-exists` reports `created: false`. Existing default-behavior tests (idempotent mkdir, intermediary dirs) still pass. `cargo fmt --all --check`, `cargo clippy -p nu-command`, and the `nu-command` test suite are clean. # After Submitting Nothing needed (no doc/`std` changes). --- _Disclosure: I use AI assistance for code review and for drafting text (English isn't my first language); I review and verify every change myself before sending it._ --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Reverts #19006
@pickx if you want to implement a new flag for this functionality instead of having it as default, have at it.