chat: do not die when HANGUP param is missing. Closes 10016
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 5 Sep 2017 17:16:40 +0000 (19:16 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 5 Sep 2017 17:16:40 +0000 (19:16 +0200)
function                                             old     new   delta
chat_main                                           1356    1379     +23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/chat.c

index 1446a040ca583bb234dd434840cf30d6c294d8cb..2dfe52c4f047f11dbad421d24c52b0d38dba3e14 100644 (file)
@@ -238,10 +238,18 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
                        , *argv
                );
                if (key >= 0) {
+                       bool onoff;
                        // cache directive value
                        char *arg = *++argv;
+
+                       if (!arg) {
+#if ENABLE_FEATURE_CHAT_TTY_HIFI
+                               tcsetattr(STDIN_FILENO, TCSAFLUSH, &tio0);
+#endif
+                               bb_show_usage();
+                       }
                        // OFF -> 0, anything else -> 1
-                       bool onoff = (0 != strcmp("OFF", arg));
+                       onoff = (0 != strcmp("OFF", arg));
                        // process directive
                        if (DIR_HANGUP == key) {
                                // turn SIGHUP on/off