patch 8.2.0095: cannot specify exit code for :cquit
Problem: Cannot specify exit code for :cquit.
Solution: Add optional argument. (Thinca, Yegappan Lakshmanan, closes #5442)
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 14b43bd..928b110 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -407,7 +407,7 @@
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
ADDR_OTHER),
EXCMD(CMD_cquit, "cquit", ex_cquit,
- EX_TRLBAR|EX_BANG,
+ EX_RANGE|EX_COUNT|EX_ZEROR|EX_TRLBAR|EX_BANG,
ADDR_NONE),
EXCMD(CMD_crewind, "crewind", ex_cc,
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index a3442ed..de8fb49 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4920,8 +4920,8 @@
static void
ex_cquit(exarg_T *eap UNUSED)
{
- getout(1); // this does not always pass on the exit code to the Manx
- // compiler. why?
+ // this does not always pass on the exit code to the Manx compiler. why?
+ getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
}
/*
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index f7c73f4..b7b4281 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -4674,4 +4674,29 @@
call delete('Xtestdir', 'rf')
endfunc
+" Test for :cquit
+func Test_cquit()
+ " Exit Vim with a non-zero value
+ if RunVim([], ["cquit 7"], '')
+ call assert_equal(7, v:shell_error)
+ endif
+
+ if RunVim([], ["50cquit"], '')
+ call assert_equal(50, v:shell_error)
+ endif
+
+ " Exit Vim with default value
+ if RunVim([], ["cquit"], '')
+ call assert_equal(1, v:shell_error)
+ endif
+
+ " Exit Vim with zero value
+ if RunVim([], ["cquit 0"], '')
+ call assert_equal(0, v:shell_error)
+ endif
+
+ " Exit Vim with negative value
+ call assert_fails('-3cquit', 'E16:')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 41a6d37..d007585 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 95,
+/**/
94,
/**/
93,