Allow building on NetBSD (#11823)

Fixes https://github.com/nushell/nushell/issues/11814
This commit is contained in:
pin 2024-02-11 15:03:17 +01:00 committed by GitHub
parent 5042f19d1b
commit 005b8b02b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -281,7 +281,12 @@ const ATTR_SET: uu_cp::Preserve = uu_cp::Preserve::Yes { required: true };
fn make_attributes(preserve: Option<Value>) -> Result<uu_cp::Attributes, ShellError> {
if let Some(preserve) = preserve {
let mut attributes = uu_cp::Attributes {
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "netbsd"
))]
ownership: ATTR_UNSET,
mode: ATTR_UNSET,
timestamps: ATTR_UNSET,
@ -296,7 +301,12 @@ fn make_attributes(preserve: Option<Value>) -> Result<uu_cp::Attributes, ShellEr
// By default preseerve only mode
Ok(uu_cp::Attributes {
mode: ATTR_SET,
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "netbsd"
))]
ownership: ATTR_UNSET,
timestamps: ATTR_UNSET,
context: ATTR_UNSET,
@ -332,7 +342,12 @@ fn parse_and_set_attribute(
Value::String { val, .. } => {
let attribute = match val.as_str() {
"mode" => &mut attribute.mode,
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "netbsd"
))]
"ownership" => &mut attribute.ownership,
"timestamps" => &mut attribute.timestamps,
"context" => &mut attribute.context,