forked from extern/nushell
Allow cp to overwrite existing files (#1339)
This commit is contained in:
parent
7a0bc6bc46
commit
427bde83f7
@ -252,7 +252,7 @@ impl Shell for FilesystemShell {
|
|||||||
|
|
||||||
if entry.is_file() {
|
if entry.is_file() {
|
||||||
let strategy = |(source_file, _depth_level)| {
|
let strategy = |(source_file, _depth_level)| {
|
||||||
if destination.exists() {
|
if destination.is_dir() {
|
||||||
let mut new_dst = dunce::canonicalize(destination.clone())?;
|
let mut new_dst = dunce::canonicalize(destination.clone())?;
|
||||||
if let Some(name) = entry.file_name() {
|
if let Some(name) = entry.file_name() {
|
||||||
new_dst.push(name);
|
new_dst.push(name);
|
||||||
|
@ -165,3 +165,22 @@ fn copies_using_a_glob() {
|
|||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn copies_same_file_twice() {
|
||||||
|
Playground::setup("cp_test_8", |dirs, _| {
|
||||||
|
nu!(
|
||||||
|
cwd: dirs.root(),
|
||||||
|
"cp \"{}\" cp_test_8/sample.ini",
|
||||||
|
dirs.formats().join("sample.ini")
|
||||||
|
);
|
||||||
|
|
||||||
|
nu!(
|
||||||
|
cwd: dirs.root(),
|
||||||
|
"cp \"{}\" cp_test_8/sample.ini",
|
||||||
|
dirs.formats().join("sample.ini")
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(dirs.test().join("sample.ini").exists());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user