1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

stty: fix output redirection (#8016)

* stty: fix output redirection

* Revert "stty: fix output redirection"

This reverts commit 604de7c4de6f51a6bcd495ccda11602c12804493.

* stty: fix output redirection by trying /dev/tty before stdout
This commit is contained in:
Will Shuttleworth 2025-06-02 08:41:25 +00:00 committed by GitHub
parent 7b41a160b4
commit dfc4072181
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)