mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cp: add support POSIXLY_CORRECT=1 when dealing with dangling links
GNU: tests/cp/thru-dangling.sh
This commit is contained in:
parent
70b69efadb
commit
2d4dfc3d7d
2 changed files with 12 additions and 0 deletions
|
@ -1498,6 +1498,7 @@ fn copy_file(
|
||||||
options.overwrite,
|
options.overwrite,
|
||||||
OverwriteMode::Clobber(ClobberMode::RemoveDestination)
|
OverwriteMode::Clobber(ClobberMode::RemoveDestination)
|
||||||
)
|
)
|
||||||
|
&& std::env::var_os("POSIXLY_CORRECT").is_none()
|
||||||
{
|
{
|
||||||
return Err(Error::Error(format!(
|
return Err(Error::Error(format!(
|
||||||
"not writing through dangling symlink '{}'",
|
"not writing through dangling symlink '{}'",
|
||||||
|
|
|
@ -1902,6 +1902,17 @@ fn test_copy_through_dangling_symlink() {
|
||||||
.stderr_only("cp: not writing through dangling symlink 'target'\n");
|
.stderr_only("cp: not writing through dangling symlink 'target'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_copy_through_dangling_symlink_posixly_correct() {
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
at.touch("file");
|
||||||
|
at.symlink_file("nonexistent", "target");
|
||||||
|
ucmd.arg("file")
|
||||||
|
.arg("target")
|
||||||
|
.env("POSIXLY_CORRECT", "1")
|
||||||
|
.succeeds();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_copy_through_dangling_symlink_no_dereference() {
|
fn test_copy_through_dangling_symlink_no_dereference() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue