From a4a3ba1dae2a5728adaa8464c962f9e8acee9399 Mon Sep 17 00:00:00 2001 From: Ulrich Hornung Date: Tue, 9 Jan 2024 21:39:14 +0100 Subject: [PATCH] windows compatibility --- src/uu/env/src/env.rs | 8 +++++++- tests/common/util.rs | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index 9f5218cb2eb..7b7073d41f0 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -20,6 +20,8 @@ use std::io::{self, Write}; use std::iter::Iterator; use std::ops::Deref; #[cfg(unix)] +use std::os::unix::ffi::OsStrExt; +#[cfg(unix)] use std::os::unix::process::ExitStatusExt; use std::process::{self}; use uucore::display::Quotable; @@ -251,7 +253,11 @@ impl EnvAppData { ) -> UResult> { let mut all_args: Vec = Vec::new(); for arg in original_args { - match arg.as_encoded_bytes() { + #[cfg(not(windows))] + let arg_bytes = arg.as_bytes(); + #[cfg(windows)] + let arg_bytes = arg.as_encoded_bytes(); + match arg_bytes { b if check_and_handle_string_args(b, "--split-string", &mut all_args, None)? => { self.had_string_argument = true; } diff --git a/tests/common/util.rs b/tests/common/util.rs index 139728e092e..487de57af80 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -12,7 +12,6 @@ use pretty_assertions::assert_eq; use rlimit::prlimit; #[cfg(feature = "sleep")] use rstest::rstest; -#[cfg(unix)] use std::borrow::Cow; use std::collections::VecDeque; #[cfg(not(windows))]