mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
fix(cp) - make "cp /dev/null target" work (#1674)
This commit is contained in:
parent
091cdd6a8d
commit
6c8af26e7f
2 changed files with 8 additions and 8 deletions
|
@ -35,7 +35,6 @@ use std::ffi::CString;
|
|||
#[cfg(windows)]
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io;
|
||||
|
@ -1233,7 +1232,14 @@ fn copy_helper(source: &Path, dest: &Path, options: &Options) -> CopyResult<()>
|
|||
};
|
||||
symlink_file(&link, &dest, &*context_for(&link, &dest))?;
|
||||
} else {
|
||||
fs::copy(source, dest).context(&*context_for(source, dest))?;
|
||||
if source.to_string_lossy() == "/dev/null" {
|
||||
/* workaround a limitation of fs::copy
|
||||
* https://github.com/rust-lang/rust/issues/79390
|
||||
*/
|
||||
File::create(dest)?;
|
||||
} else {
|
||||
fs::copy(source, dest).context(&*context_for(source, dest))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -911,14 +911,8 @@ fn test_cp_target_file_dev_null() {
|
|||
let file1 = "/dev/null";
|
||||
let file2 = "test_cp_target_file_file_i2";
|
||||
|
||||
at.touch(file1);
|
||||
at.touch(file2);
|
||||
ucmd.arg(file1).arg(file2).fails();
|
||||
|
||||
/* Uncomment when fixed
|
||||
ucmd.arg(file1).arg(file2).succeeds().no_stderr();
|
||||
|
||||
assert!(at.file_exists(file1));
|
||||
assert!(at.file_exists(file2));
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue