Browse Source

vi: add 'ZQ' quitting command

Busybox vi provides the 'ZZ' command to save and close
the similar 'ZQ' command just exits without saving.

function                                             old     new   delta
do_cmd                                              4222    4244     +22

Signed-off-by: Grob Grobmann <grobgrobmann@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

-----

also cherry-pick fe73c8d55795a8fe7e95fc2c00af6899817b96b8

*: style fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Grob Grobmann 3 years ago
parent
commit
57ea282f94
1 changed files with 7 additions and 1 deletions
  1. 7 1
      editors/vi.c

+ 7 - 1
editors/vi.c

@@ -4216,8 +4216,14 @@ static void do_cmd(int c)
             goto dc_i;  // start inserting
         break;
     case 'Z':           // Z- if modified, {write}; exit
-        // ZZ means to save file (if necessary), then exit
         c1 = get_one_char();
+        // ZQ means to exit without saving
+        if (c1 == 'Q') {
+            editing = 0;
+            options.optind = cmdline_filecnt;
+            break;
+        }
+        // ZZ means to save file (if necessary), then exit
         if (c1 != 'Z') {
             indicate_error();
             break;