3 ms·
cooked mode also generally gives input to the program a line at a time and handles things like backspace to delete characters, and it handles program output too
by lilyball 2y ago
cooked mode also generally gives input to the program a line at a time and handles things like backspace to delete characters, and it handles program output too, doing things like replacing \n with \r\n.
- teddyh 2y agoNo, line-by-line vs. character-by-character is a separate mode from “cooked” mode. See “stty extproc”.
- lilyball 2y agoI read up on this and "cooked but character-by-character" is apparently something called "cbreak mode" (or "rare mode").
- teddyh 2y agoAccording to stty(1), ”cbreak” is a negative alias of “icanon”, which simply enables the special functions of the ‘erase’ (backspace), ‘kill’ (Ctrl-U), ‘werase’ (Ctrl-W), and ‘rprnt’ (Ctrl-R) keybindings. “cooked” mode includes “icanon”. So no, I do not think that what you wrote is correct. From what I can tell, the line-by-line mode is “extproc”.
- lilyball 2y agoOn macOS, running `stty cbreak; tr a-zA-Z A-Za-z` causes `tr` to immediately transform every character as it's typed. If I SSH into a linux box that doesn't work, though I'm wondering if that's SSH's fault (it's not convenient right now to get direct access). Certainly the Linux manpage for stty(1) documents a setting min N with -icanon, set N characters minimum for a completed read which suggests that if you set -icanon (e.g. cbreak) then reads may complete after 1 character. Also on macOS the documentation for cbreak is different, it lists a bunch of settings including -icanon, it's Linux that makes it literally an alias for -icanon.