From 50085d7a0ec847e6a5e6d16fcde1fb4557ba0606 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 25 Dec 2025 15:52:33 +0100 Subject: [PATCH] printenv: add a test for non-utf-8 var Like in : 5d4abd88e95c628310d0a79c341cae25b51e8345 --- tests/by-util/test_printenv.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_printenv.rs b/tests/by-util/test_printenv.rs index 71f22c984..28ca045bd 100644 --- a/tests/by-util/test_printenv.rs +++ b/tests/by-util/test_printenv.rs @@ -117,3 +117,16 @@ fn test_non_utf8_value() { ); result.stdout_is_bytes(b"/tmp/lib.so\xff\n"); } + +#[test] +#[cfg(unix)] +fn test_non_utf8_env_vars() { + use std::ffi::OsString; + use std::os::unix::ffi::OsStringExt; + + let non_utf8_value = OsString::from_vec(b"hello\x80world".to_vec()); + new_ucmd!() + .env("NON_UTF8_VAR", &non_utf8_value) + .succeeds() + .stdout_contains_bytes(b"NON_UTF8_VAR=hello\x80world"); +}