mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
cp: make cp -a not fail on Windows
Before this commit, `cp -a` would terminate with a non-zero status code on Windows because there are no extended attributes (xattr) to copy. However, the GNU documentation for cp states > Try to preserve SELinux security context and extended attributes > (xattr), but ignore any failure to do that and print no > corresponding diagnostic. so it seems reasonable to do nothing instead of exiting with an error in this case.
This commit is contained in:
parent
cee6c25cc4
commit
cd3f7b89a7
1 changed files with 10 additions and 1 deletions
|
@ -1146,7 +1146,16 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu
|
||||||
}
|
}
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
{
|
{
|
||||||
return Err("XAttrs are only supported on unix.".to_string().into());
|
// The documentation for GNU cp states:
|
||||||
|
//
|
||||||
|
// > Try to preserve SELinux security context and
|
||||||
|
// > extended attributes (xattr), but ignore any failure
|
||||||
|
// > to do that and print no corresponding diagnostic.
|
||||||
|
//
|
||||||
|
// so we simply do nothing here.
|
||||||
|
//
|
||||||
|
// TODO Silently ignore failures in the `#[cfg(unix)]`
|
||||||
|
// block instead of terminating immediately on errors.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue