我正在阅读 Bruce Molay 的《Understanding Unix/Linux Programming》。在第 5 章中,本书介绍了一个新命令stty
,可以帮助您配置终端设置。
书中提到的一个例子是用来stty -echo
关闭回声,然后我在我的Mac上尝试了它,但发现它根本不起作用。
// here is some infomation about my mac
Mac mini (M1, 2020)
OS version: 11.4
// by the way, I also tested it on my old intel mac, and I got the same result
Macbook Pro(Early 2015)
OS version: 10.15.6
// here are the commands I used in the terminal on Mac
➜ ~ stty -a # check the old 'echo bit' status
speed 38400 baud; 45 rows; 139 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;
➜ ~ stty -echo # turn off echo bit
➜ ~ stty -a # see the results
speed 38400 baud; 45 rows; 139 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
-extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
stop = ^S; susp = ^Z; time = 0; werase = ^W;
然后我在一个ubuntu docker 容器中对其进行了测试,并且stty -echo
运行良好。
那么为什么它不能在 macOS 上运行呢?