From 493bc9b399fb3c97f5b7243fb21aac2960437057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 21 Nov 2025 04:17:16 +0100 Subject: [PATCH 1/6] stty/flags: Do not show tandem option It is just an alias for ixoff, and it's marked with `OMIT` in GNU version --- src/uu/stty/src/flags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 9fd3f3d757a..17873861448 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -71,8 +71,8 @@ pub const INPUT_FLAGS: &[Flag] = &[ Flag::new("igncr", I::IGNCR), Flag::new("icrnl", I::ICRNL).sane(), Flag::new("ixoff", I::IXOFF), - Flag::new("tandem", I::IXOFF), Flag::new("ixon", I::IXON), + Flag::new("tandem", I::IXOFF).hidden(), // not supported by nix // Flag::new("iuclc", I::IUCLC), Flag::new("ixany", I::IXANY), From 68390fdac9472ace427d5306c3dab2ed0b5b8eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 21 Nov 2025 04:19:22 +0100 Subject: [PATCH 2/6] stty/flags: Use same order of GNU in printing ixoff/ixon Now the order is respected --- src/uu/stty/src/flags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 17873861448..8cb3ef0b0dc 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -70,8 +70,8 @@ pub const INPUT_FLAGS: &[Flag] = &[ Flag::new("inlcr", I::INLCR), Flag::new("igncr", I::IGNCR), Flag::new("icrnl", I::ICRNL).sane(), - Flag::new("ixoff", I::IXOFF), Flag::new("ixon", I::IXON), + Flag::new("ixoff", I::IXOFF), Flag::new("tandem", I::IXOFF).hidden(), // not supported by nix // Flag::new("iuclc", I::IUCLC), From f9fddd641ab4b2bf5b2bce4c6fdeae4036b27795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 21 Nov 2025 04:20:17 +0100 Subject: [PATCH 3/6] stty/flags: Add missing tabs combination setting --- src/uu/stty/src/flags.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 8cb3ef0b0dc..54bb0b4727d 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -370,4 +370,5 @@ pub const COMBINATION_SETTINGS: &[(&str, bool)] = &[ ("pass8", true), ("raw", true), ("sane", false), + ("tabs", true), ]; From a3408a7498addf7bb7266e39e8a3fbbbdbfab031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 21 Nov 2025 04:22:13 +0100 Subject: [PATCH 4/6] stty/flags: Add delayed suspend (dsusp) support It's only supported by BSD, aix and solaris, but still available in nix --- src/uu/stty/src/flags.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index 54bb0b4727d..ae92169275c 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -7,7 +7,7 @@ // spell-checker:ignore ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl ixoff ixon iuclc ixany imaxbel iutf // spell-checker:ignore opost olcuc ocrnl onlcr onocr onlret ofdel nldly crdly tabdly bsdly vtdly ffdly // spell-checker:ignore isig icanon iexten echoe crterase echok echonl noflsh xcase tostop echoprt prterase echoctl ctlecho echoke crtkill flusho extproc -// spell-checker:ignore lnext rprnt susp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase +// spell-checker:ignore lnext rprnt susp dsusp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase VDSUSP // spell-checker:ignore sigquit sigtstp // spell-checker:ignore cbreak decctlq evenp litout oddp @@ -342,6 +342,18 @@ pub const CONTROL_CHARS: &[(&str, S)] = &[ ("stop", S::VSTOP), // Sends a suspend signal (SIGTSTP). ("susp", S::VSUSP), + #[cfg(any( + target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "aix", + target_os = "solaris" + ))] + // Sends a delayed suspend signal (SIGTSTP). + ("dsusp", S::VDSUSP), // Reprints the current line. ("rprnt", S::VREPRINT), // Deletes the last word typed. From 2e984fccd81470d674a4a4d86bc6044ee6d61d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 21 Nov 2025 04:23:52 +0100 Subject: [PATCH 5/6] stty/flags: List all missing flags that GNU version supports List the remaining flags that GNU stty support, they cannot be be all listed yet since we have no nix support for them, but it's better to keep the lists in sync so that it's easier to enable what will be supported in future --- src/uu/stty/src/flags.rs | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index ae92169275c..d1bb0f7a6c2 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -10,6 +10,7 @@ // spell-checker:ignore lnext rprnt susp dsusp swtch vdiscard veof veol verase vintr vkill vlnext vquit vreprint vstart vstop vsusp vswtc vwerase werase VDSUSP // spell-checker:ignore sigquit sigtstp // spell-checker:ignore cbreak decctlq evenp litout oddp +// spell-checker:ignore cdtrdsr CDTRDSR ofill OFILL dsusp VDSUSP VFLUSHO VSTATUS noncanonical VMIN deciseconds noncanonical VTIME use crate::Flag; @@ -54,10 +55,14 @@ pub const CONTROL_FLAGS: &[Flag] = &[ Flag::new_grouped("cs7", C::CS7, C::CSIZE), Flag::new_grouped("cs8", C::CS8, C::CSIZE).sane(), Flag::new("hupcl", C::HUPCL), + // Not supported by nix and libc. + // Flag::new("hup", C::HUP).hidden(), Flag::new("cstopb", C::CSTOPB), Flag::new("cread", C::CREAD).sane(), Flag::new("clocal", C::CLOCAL), Flag::new("crtscts", C::CRTSCTS), + // Not supported by nix and libc. + // Flag::new("cdtrdsr", C::CDTRDSR), ]; pub const INPUT_FLAGS: &[Flag] = &[ @@ -73,8 +78,16 @@ pub const INPUT_FLAGS: &[Flag] = &[ Flag::new("ixon", I::IXON), Flag::new("ixoff", I::IXOFF), Flag::new("tandem", I::IXOFF).hidden(), - // not supported by nix - // Flag::new("iuclc", I::IUCLC), + #[cfg(any( + target_os = "aix", + target_os = "android", + target_os = "cygwin", + target_os = "haiku", + target_os = "hurd", + target_os = "nto", + target_os = "linux" + ))] + Flag::new("iuclc", I::IUCLC), Flag::new("ixany", I::IXANY), Flag::new("imaxbel", I::IMAXBEL).sane(), #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] @@ -101,6 +114,14 @@ pub const OUTPUT_FLAGS: &[Flag] = &[ target_os = "linux", target_os = "macos" ))] + Flag::new("ofill", O::OFILL), + #[cfg(any( + target_os = "android", + target_os = "haiku", + target_os = "ios", + target_os = "linux", + target_os = "macos" + ))] Flag::new("ofdel", O::OFDEL), #[cfg(any( target_os = "android", @@ -242,8 +263,13 @@ pub const LOCAL_FLAGS: &[Flag] = &[ Flag::new("echok", L::ECHOK).sane(), Flag::new("echonl", L::ECHONL), Flag::new("noflsh", L::NOFLSH), - // Not supported by nix - // Flag::new("xcase", L::XCASE), + #[cfg(any( + target_os = "aix", + target_os = "android", + target_os = "haiku", + target_os = "linux", + ))] + Flag::new("xcase", L::XCASE), Flag::new("tostop", L::TOSTOP), #[cfg(not(target_os = "cygwin"))] Flag::new("echoprt", L::ECHOPRT), @@ -362,6 +388,25 @@ pub const CONTROL_CHARS: &[(&str, S)] = &[ ("lnext", S::VLNEXT), // Discards the current line. ("discard", S::VDISCARD), + // deprecated compat option. + // Not supported by nix and libc. + // ("flush", S::VFLUSHO), + #[cfg(any( + target_os = "freebsd", + target_os = "dragonfly", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + ))] + // Status character + ("status", S::VSTATUS), + // Minimum number of characters for noncanonical read. + // We handle this manually. + // ("min", S::VMIN), + // Timeout in deciseconds for noncanonical read. + // We handle this manually. + // ("time", S::VTIME), ]; /// This constant lists all possible combination settings, using a bool to represent if the setting is negatable From 4ca3dd256c41c72329fda39976ac998f68b2e673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 22 Nov 2025 05:15:15 +0100 Subject: [PATCH 6/6] stty: Use c_line (as line_discipline) from nix Nix now supports the line discipline parameter in various platforms, so use upstream definition instead of going through libc See: https://github.com/nix-rust/nix/issues/1802 --- src/uu/stty/src/stty.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index 686f00a823e..45b2b3c1991 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -688,12 +688,9 @@ fn print_terminal_size( ); } - #[cfg(any(target_os = "linux", target_os = "redox"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "haiku"))] { - // For some reason the normal nix Termios struct does not expose the line, - // so we get the underlying libc::termios struct to get that information. - let libc_termios: nix::libc::termios = termios.clone().into(); - let line = libc_termios.c_line; + let line = termios.line_discipline; printer.print(&translate!("stty-output-line", "line" => line)); } printer.flush(); @@ -1056,7 +1053,7 @@ fn apply_special_setting( )] SpecialSetting::Line(n) => { // nix only defines Termios's `line_discipline` field on these platforms - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "haiku"))] { _termios.line_discipline = *n; }