fix wrong error msg of save command on windows (#14699)

fixes #14664 

# Description

Now,

```nu
"aaa" | save -f ..
```

returns correct error message on windows.

Note that the fix introduces a TOCTOU problem, which only effects the
error message. It won't break any workload.

# User-Facing Changes

The fix won't break any workload.

# Tests + Formatting

I have run tests **only on windows**.

# After Submitting

The fix doesn't need to change documentation.
This commit is contained in:
Chen1Plus
2025-01-07 07:36:42 +08:00
committed by GitHub
parent 9ed2ca792f
commit ac12b02437
2 changed files with 25 additions and 1 deletions

View File

@ -525,3 +525,12 @@ fn parent_redirection_doesnt_affect_save() {
assert_eq!(actual.trim_end(), "");
})
}
#[test]
fn force_save_to_dir() {
let actual = nu!(cwd: "crates/nu-command/tests/commands", r#"
"aaa" | save -f ..
"#);
assert!(actual.err.contains("Is a directory"));
}