stty: fix output redirection (#8016)

* stty: fix output redirection

* Revert "stty: fix output redirection"

This reverts commit 604de7c4de.

* stty: fix output redirection by trying /dev/tty before stdout
This commit is contained in:
Will Shuttleworth
2025-06-02 10:41:25 +02:00
committed by GitHub
parent 7b41a160b4
commit dfc4072181
+12 -1
View File
@@ -142,7 +142,18 @@ impl<'a> Options<'a> {
.custom_flags(O_NONBLOCK)
.open(f)?,
),
None => Device::Stdout(stdout()),
// default to /dev/tty, if that does not exist then default to stdout
None => {
if let Ok(f) = std::fs::OpenOptions::new()
.read(true)
.custom_flags(O_NONBLOCK)
.open("/dev/tty")
{
Device::File(f)
} else {
Device::Stdout(stdout())
}
}
},
settings: matches
.get_many::<String>(options::SETTINGS)