Skip to content

stty: drop incorrect flags for apple target - #15417

Closed
oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:stty-a
Closed

oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:stty-a

Conversation

@oech3

@oech3 oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

I don't like diff given by cargo fmt.

@xtqqczze

xtqqczze commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator
$ rustc --print host-tuple                                                   
aarch64-apple-darwin
$ cargo run -q --features unix stty --all

Diff from this change:

@@ -5,6 +5,6 @@ discard = ^O; min = 1; time = 0;
 -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
 -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixoff -tandem
 ixon ixany imaxbel iutf8
-opost -ocrnl onlcr -onocr -onlret -ofdel nl0 cr0 tab0 bs0 vt0 ff0
+opost -ocrnl onlcr -onocr -onlret
 isig icanon iexten echo echoe echok -echonl -noflsh -tostop -echoprt echoctl
 echoke -flusho -extproc

@xtqqczze

Copy link
Copy Markdown
Collaborator

@collinfunk GNU stty output includes -ofdel nl0 cr0 tab0 bs0 vt0 ff0 flags for Apple targets, but the Apple headers state:

The following block of features is unimplemented. Use of these flags in programs will currently result in unexpected behaviour.

@oech3

oech3 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

I think kernel should reject them with EINVAL even if it was given to kernel. Should GNU remove them too?
I think those flags are useful to share --all's output as config with different platforms.
@pixelb

@oech3
oech3 marked this pull request as draft October 16, 2026 13:34
@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

This is probably why nix crate expose them...

@xtqqczze

Copy link
Copy Markdown
Collaborator

These are all flags required by POSIX, so I'm not sure we should exclude them even Apple does not implement them:

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/termios.h.html

@oech3

This comment was marked as outdated.

@oech3

oech3 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

I think we can drop them if they are bottom of struct.

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

One of an another reason for removing them is compatibility with stty installed on macOS by default.

@xtqqczze

xtqqczze commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

It seems macOS stty does not error with flags such as ofdel (but does with olcuc).

$ stty ofdel
$ stty nl0
$ stty cr0
$ stty tab0
$ stty bs0
$ stty vt0
$ stty ff0
$ stty olcuc
stty: illegal option -- olcuc
usage: stty [-a | -e | -g] [-f file] [arguments]

So I think we should not make this change.

@oech3 oech3 closed this Oct 17, 2026
@oech3
oech3 deleted the stty-a branch October 17, 2026 08:51
@xtqqczze

Copy link
Copy Markdown
Collaborator

@oech3 Should nix-rust/nix#2846 be closed?

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Sure

@xtqqczze

Copy link
Copy Markdown
Collaborator

@oech3 For bytecodealliance/rustix#1706, does rustix lack support for any flags on Apple targets?

@oech3

oech3 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

I think we can edit issue title to request unimplemented flags. But I think usecase is too nich to request.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Which specific flags are unimplemented in rustix for Apple targets?

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Same with flags this PR tried to drop?

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Oh... rustix expose some unimplemented flags e.g. OCRNL... So for consistency, we should request to add them...

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Do we need to support unimplemented flags also on other BSDs?

@xtqqczze

Copy link
Copy Markdown
Collaborator

Same with flags this PR tried to drop?

So your claim is rustix does not support the following flags for Apple targets?

  • ofdel
  • nl0
  • cr0
  • tab0
  • bs0
  • vt0
  • ff0

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Yes.

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Sorry. TAB0 is given.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Do we need to support unimplemented flags also on other BSDs?

If they are POSIX I would think so.

https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/termios.h.html

@xtqqczze

Copy link
Copy Markdown
Collaborator

I've addressed the missing flags for Apple targets upstream in bytecodealliance/rustix#1709.

@xtqqczze

Copy link
Copy Markdown
Collaborator

Do we need to support unimplemented flags also on other BSDs?

Since they are not implemented in libc crate for other BSDs, nothing we can do for now.

@oech3

oech3 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

On FreeBSD CI:

  script -q /dev/null gstty --all
  Warning: Permanently added '[127.0.0.1]:10022' (ED25519) to the list of known hosts.
  ^D��speed 9600 baud; rows 0; columns 0;
  intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y; rprnt = ^R;
  werase = ^W; lnext = ^V; discard = ^O; status = ^T; min = 1; time = 0;
  -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
  -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
  ixany imaxbel iutf8
  opost -ocrnl onlcr -onocr -onlret tab0
  isig icanon iexten echo echoe -echok -echonl -noflsh -tostop -echoprt echoctl
  echoke -flusho -extproc

Failed to do same things on OpenBSD.

@xtqqczze

Copy link
Copy Markdown
Collaborator

So there is no issue for other BSD?

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

I think so. But stty under script command might change something.
@lcheylus @0323pin Would you share gnu-stty --all under *BSD?

@0323pin

0323pin commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@oech3

On NetBSD

~> gnu-stty --all
Exception: exec: "gnu-stty": executable file not found in $PATH
~> stty --all
stty: illegal option -- --all
usage: stty [-a|-e|-g] [-f file] [operand ...]
Exception: stty exited with 1

https://man.netbsd.org/stty.1

@oech3

oech3 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

My bad. Would you try gstty --all of coreutils package https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/sysutils/coreutils/index.html ?

@lcheylus

Copy link
Copy Markdown
Contributor

On OpenBSD current/amd64, with GNU coreutils installed via coreutils package.

$ gstty --all
speed 115200 baud; rows 67; columns 273;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; status = <undef>; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret tab0
isig icanon iexten echo echoe -echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

@0323pin

0323pin commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

My bad. Would you try gstty --all of coreutils package https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/sysutils/coreutils/index.html ?

Sure ... I had to build it because, I usually don't have it installed. Hence, the slight delay 😆

So, on NetBSD dev branch ...

gstty --all
speed 9600 baud; rows 44; columns 187;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; dsusp = ^Y; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O;
status = ^T; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff ixany imaxbel
opost -ocrnl onlcr -onocr -onlret
isig icanon iexten echo echoe -echok -echonl -noflsh -tostop -echoprt echoctl echoke -flusho -extproc

@oech3

oech3 commented Oct 17, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

4 participants