Revert "nohup: Succeed in creating ~/nohup.out for non-UTF8 HOME"

This commit is contained in:
Sylvestre Ledru
2026-03-05 09:38:56 +01:00
committed by Daniel Hofstetter
parent e6a3bb596f
commit 1124685d8c
2 changed files with 2 additions and 22 deletions
+2 -2
View File
@@ -150,12 +150,12 @@ fn find_stdout() -> UResult<File> {
Ok(t)
}
Err(e1) => {
let Some(home) = env::var_os("HOME") else {
let Ok(home) = env::var("HOME") else {
return Err(NohupError::OpenFailed(internal_failure_code, e1).into());
};
let mut homeout = PathBuf::from(home);
homeout.push(NOHUP_OUT);
let homeout_str = homeout.to_string_lossy();
let homeout_str = homeout.to_str().unwrap();
match OpenOptions::new().create(true).append(true).open(&homeout) {
Ok(t) => {
show_error!(
-20
View File
@@ -247,23 +247,3 @@ fn test_nohup_stderr_to_stdout() {
assert!(content.contains("stdout message"));
assert!(content.contains("stderr message"));
}
#[test]
#[cfg(all(unix, not(target_os = "macos")))]
fn test_nohup_non_utf8_home() {
use std::{ffi::OsStr, os::unix::ffi::OsStrExt};
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.mkdir("nohup.out");
at.mkdir(OsStr::from_bytes(b"nohup_home\x80"));
let path = at.plus(OsStr::from_bytes(b"nohup_home\x80"));
ts.ucmd()
.terminal_simulation(true)
.env("HOME", path.as_os_str())
.args(&["true"])
.succeeds();
assert!(at.file_exists(path.join("nohup.out")));
}