coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

stty erase returns "invalid argument" on MacOS

Open vigna opened this issue 11 months ago • 3 comments

On MacOS stty returns an error instead of setting the erase character.

/bin/stty erase ^H

works as expected. But (from MacPorts)

/opt/local/libexec/uutils/stty erase ^H
/opt/local/libexec/uutils/stty: invalid argument 'erase'

Nonetheless, erase is listed as a control character:

/opt/local/libexec/uutils/stty -a
speed 9600 baud; rows 54; columns 169; 
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; 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 
isig icanon iexten echo echoe -echok -echonl -noflsh -tostop -echoprt echoctl echoke -flusho -extproc 

This behavior has also been replicated in debug mode on the current repo:

cargo build --bin coreutils --features macos
./target/debug/coreutils stty erase ^H
stty: invalid argument 'erase'

vigna avatar Feb 25 '25 07:02 vigna

Thanks for filing! Here's a bit of guidance for people who want to look into this. This seems to be part of https://github.com/uutils/coreutils/issues/3861, because setting special characters is not supported yet. So it's not just erase but all control characters.

tertsdiepraam avatar Feb 25 '25 08:02 tertsdiepraam

Hi! Could I be assigned this issue? I'm interested in resolving it.

Thank you!

hiperbolt avatar Mar 02 '25 01:03 hiperbolt

I'm interested in working on this issue. I'd like to use a similar approach to this. But instead of using apply_flag(...), maybe create a new function like apply_char_mapping(...) as the control characters are not flags.

willshuttleworth avatar May 11 '25 20:05 willshuttleworth

Fixed by https://github.com/uutils/coreutils/pull/7931

cakebaker avatar Jun 05 '25 14:06 cakebaker