From 2981558e1057a50fd78036e9e82383cbfce8d084 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Thu, 2 Nov 2023 17:00:13 +0900 Subject: [PATCH] stty: 'raw', 'cooked' options --- apps/stty.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/stty.c b/apps/stty.c index 7d2914c7..6776d2aa 100644 --- a/apps/stty.c +++ b/apps/stty.c @@ -331,6 +331,22 @@ int main(int argc, char * argv[]) { continue; } + if (!strcmp(argv[i], "raw")) { + t.c_iflag = 0; /* no input processing */ + t.c_oflag &= ~OPOST; /* no postprocessing of output */ + t.c_lflag &= ~(ISIG | ICANON | XCASE); + i++; + continue; + } + + if (!strcmp(argv[i], "cooked")) { + t.c_iflag |= ICRNL | BRKINT; + t.c_oflag |= OPOST; + t.c_lflag |= ISIG | ICANON; + i++; + continue; + } + if (!strcmp(argv[i], "size")) { show_size(); @@ -429,6 +445,6 @@ int main(int argc, char * argv[]) { return 1; } - tcsetattr(STDERR_FILENO, TCSAFLUSH, &t); + tcsetattr(STDERR_FILENO, TCSADRAIN, &t); return 0; }