Skip to content

Improve the stty --all output to match GNU version - #9432

Open
3v1n0 wants to merge 7 commits into
uutils:mainfrom
3v1n0:stty-better-printing
Open

3v1n0 wants to merge 7 commits into
uutils:mainfrom
3v1n0:stty-better-printing

Conversation

@3v1n0

@3v1n0 3v1n0 commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor

The output of stty --all was not really matching GNU one, adjust it to follow the same logic

Before:

--- /tmp/gnu-stty	2025-11-21 01:41:14.909020716 +0100
+++ /tmp/rust-stty	2025-11-21 00:38:42.324215733 +0100
@@ -1,10 +1,6 @@
-speed 38400 baud; rows 57; columns 112; line = 0;
-intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
-eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
-werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
--parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
--ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
--iuclc -ixany -imaxbel iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke -flusho -extproc
+speed 38400 baud; rows 57; columns 115; line = 0;
+intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
+-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts 
+-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixoff -tandem ixon -ixany -imaxbel iutf8 
+opost -olcuc -ocrnl onlcr -onocr -onlret -ofdel nl0 cr0 tab0 bs0 vt0 ff0 
+isig icanon iexten echo echoe echok -echonl -noflsh -tostop -echoprt echoctl echoke -flusho -extpro```

After:

--- /tmp/gnu-stty	2025-11-21 01:41:14.909020716 +0100
+++ /tmp/rust-stty	2025-11-21 04:31:16.511313289 +0100
@@ -4,7 +4,7 @@
 werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
 -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
 -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
--iuclc -ixany -imaxbel iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke -flusho -extproc
+-ixany -imaxbel iutf8
+opost -olcuc -ocrnl onlcr -onocr -onlret -ofdel nl0 cr0 tab0 bs0 vt0 ff0
+isig icanon iexten echo echoe echok -echonl -noflsh -tostop -echoprt echoctl
+echoke -flusho -extproc

Highlight is not great for word diffing, but well:

❯ wdiff /tmp/stty-out /tmp/rstty-out 
speed 38400 baud; rows 57; columns 112; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
[--iuclc-]
-ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret [--ofill-] -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh [--xcase-] -tostop -echoprt echoctl
echoke -flusho -extpro

After the flags we're missing will be included upstream, the diff will be actually none.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/cksum/cksum-base64-untagged. tests/cksum/cksum-base64-untagged is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@3v1n0
3v1n0 force-pushed the stty-better-printing branch 2 times, most recently from b287c72 to 9c6d77f Compare November 21, 2025 06:33
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@3v1n0
3v1n0 force-pushed the stty-better-printing branch 2 times, most recently from 46cbbc3 to b989937 Compare November 21, 2025 06:57
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/cksum/cksum-base64-untagged is no longer failing!

@3v1n0
3v1n0 force-pushed the stty-better-printing branch from b989937 to bae055d Compare November 21, 2025 07:32
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/cksum/cksum-base64-untagged is no longer failing!

Comment thread src/uu/stty/src/flags.rs
// Status character
// ("status", S::VSTATUS), // Not supported by nix
// Minimum number of characters for noncanonical read.
// ("min", S::VMIN),

@ChrisDryden ChrisDryden Nov 21, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the nix compatibility is more about the platform that it is being built on?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the code, but there are no such definitions... I wanted to submit a change there too, but I'm unsure about what platforms are supported, so I'd rather wait for someone having it to support it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this specific case, actually it was defined, but I commented this out since we use the value differently in the code

Comment thread src/uu/stty/src/flags.rs Outdated
3v1n0 added a commit to 3v1n0/nix that referenced this pull request Nov 21, 2025
@3v1n0 3v1n0 mentioned this pull request Nov 21, 2025
1 of 3 tasks
@3v1n0
3v1n0 force-pushed the stty-better-printing branch from bae055d to 173ad5a Compare November 21, 2025 22:04
Comment thread src/uu/stty/src/flags.rs Outdated
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

3v1n0 added a commit to 3v1n0/nix that referenced this pull request Nov 21, 2025
3v1n0 added a commit to 3v1n0/nix that referenced this pull request Nov 21, 2025
@3v1n0
3v1n0 force-pushed the stty-better-printing branch from 173ad5a to 65b5c7a Compare November 21, 2025 23:57
3v1n0 added a commit to 3v1n0/nix that referenced this pull request Nov 22, 2025
3v1n0 added a commit to 3v1n0/nix that referenced this pull request Nov 22, 2025
@3v1n0
3v1n0 force-pushed the stty-better-printing branch 5 times, most recently from 704772b to fa39e80 Compare November 22, 2025 04:00
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@sylvestre
sylvestre force-pushed the stty-better-printing branch from f0de189 to 61ce79b Compare November 22, 2025 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Moderate findings remain regarding platform-condition consistency and regression-test precision.

1 open finding

🧠 Review effort: Lite

@3v1n0
3v1n0 force-pushed the stty-better-printing branch from f7af8cb to 7ac48c8 Compare October 16, 2026 15:24
Copilot AI lite review requested due to automatic review settings October 16, 2026 15:24
@3v1n0

3v1n0 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

You can simplify cfg by custom cfg: bsd given by cfg_aliases.

Done, thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Haiku-specific code currently fails with the locked nix version, and output tests do not verify formatting or flag ordering.

1 open finding
1 resolved since last review

🧠 Review effort: Lite

Comment thread src/uu/stty/src/stty.rs
Comment thread src/uu/stty/src/flags.rs Outdated
Copilot AI lite review requested due to automatic review settings October 16, 2026 15:54
@3v1n0
3v1n0 force-pushed the stty-better-printing branch from 7ac48c8 to 6868d67 Compare October 16, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Strengthen the output test to verify signed tokens, values, and ordering.

2 open findings

🧠 Review effort: Lite

Comment thread tests/by-util/test_stty.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two moderate Haiku compatibility issues remain in stty.rs.

0 open findings

2 resolved since last review

🧠 Review effort: Lite

Comment thread src/uu/stty/src/stty.rs Outdated
(S::VLNEXT, "^V"),
#[cfg(not(any(target_os = "aix", target_os = "haiku")))]
(S::VDISCARD, "^O"),
#[cfg(any(bsd, target_os = "aix", target_os = "illumos", target_os = "solaris"))]

@xtqqczze xtqqczze Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg(any(bsd, target_os = "aix", target_os = "illumos", target_os = "solaris"))]
#[cfg(any(bsd, solarish, target_os = "aix"))]

you can make this kind of change throughout by adding the following cfg alias to src/uu/stty/build.rs:

solarish: { any(target_os = "illumos", target_os = "solaris") }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add aliases like:

freebsdlike: { any(dragonfly, freebsd) },
netbsdlike: { any(netbsd, openbsd) },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how many people can understand them. (But bsd including apple is already crazy).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we add linux_kernel only for stty?

Comment thread src/uu/stty/src/stty.rs

#[cfg(any(bsd, target_os = "aix", target_os = "illumos", target_os = "solaris"))]
#[test]
fn test_get_sane_control_char_dsusp() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix cspell

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-platform terminal behavior requires final human validation.

0 open findings

🧠 Review effort: Lite

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

I'd like to have #15425 before this.

Comment thread src/uu/stty/build.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The NTO test assertion must be fixed or the corresponding flag support added.

1 open finding

🧠 Review effort: Lite

Comment thread tests/by-util/test_stty.rs
3v1n0 added 7 commits October 16, 2026 17:19
Rather than repeating file-level `spell-checker:ignore` comments,
register the stty-specific words in the shared workspace dictionary
so that they are covered everywhere, as suggested in review.
nix cfg-gates some termios flags and control characters out on
certain platforms, but stty referenced them unconditionally, so
the crate could not be built there at all: Haiku misses VREPRINT,
VLNEXT, VWERASE, VDISCARD, IMAXBEL, EXTPROC, B460800 and B921600,
and AIX misses VDISCARD, VWERASE, EXTPROC, CRTSCTS and the same
high baud rates.

Gate the affected definitions with the same predicates nix uses,
so that the crate compiles on every target where its dependencies
do, as prerequisite for the Haiku support that follows.
It is just an alias for ixoff, and it's marked with `OMIT` in GNU
version
Enable the remaining GNU flags that nix exposes as well (iuclc, ofill,
ofdel and xcase), and list as comments the ones that are not supported
by nix and libc (hup, cdtrdsr, flush) or that are handled manually
(min and time), so that the lists stay in sync with GNU and it's easier
to enable what will be supported in the future.
It's only supported by BSD, aix and solaris, but still available in nix.

We need to define a sane default for VDSUSP (^Y)
Nix exposes the Termios line discipline field only on linux, android
and haiku, so use it there and keep reading c_line through libc on
redox, where nix does not provide the field. On Haiku the field is a
c_char, so convert the value from u8 when setting it.

See: nix-rust/nix#1802
@3v1n0

3v1n0 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

I'd like to have #15425 before this.

Ok, fair enough.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Apple-target configuration is missing, causing the added integration test to fail before exercising --all.

1 open finding
1 resolved since last review

🧠 Review effort: Lite

Comment thread src/uu/stty/src/flags.rs
Comment on lines +393 to +395
#[cfg(any(bsd, solarish, target_os = "aix"))]
// Sends a delayed suspend signal (SIGTSTP).
("dsusp", S::VDSUSP),
Comment thread src/uu/stty/src/flags.rs
#[cfg(not(any(target_os = "redox", target_os = "aix")))]
Flag::new("crtscts", C::CRTSCTS),
// Not supported by nix and libc.
// Flag::new("cdtrdsr", C::CDTRDSR),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CDTRDSR is not defined in POSIX termios.h, which platforms define it?

Comment thread src/uu/stty/src/flags.rs
("discard", S::VDISCARD),
// deprecated compat option.
// Not supported by nix and libc.
// ("flush", S::VFLUSHO),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not defined in POSIX, which platforms support it?

Comment thread src/uu/stty/src/stty.rs
#[cfg(not(any(target_os = "linux", target_os = "redox")))]
#[cfg(target_os = "redox")]
{
// nix does not expose the line discipline on Redox, so we get the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants