Patch 8.2.0095
Problem: Cannot specify exit code for :cquit.
Solution: Add optional argument. (Thinca, Yegappan Lakshmanan, closes #5442)
Files: runtime/doc/quickfix.txt, src/ex_cmds.h, src/ex_docmd.c,
src/testdir/test_quickfix.vim
*** ../vim-8.2.0094/runtime/doc/quickfix.txt 2019-12-17 21:27:14.690319902
+0100
--- runtime/doc/quickfix.txt 2020-01-06 21:44:46.608599310 +0100
***************
*** 229,236 ****
current window is used instead of the quickfix list.
*:cq* *:cquit*
! :cq[uit][!] Quit Vim with an error code, so that the compiler
! will not compile the same file again.
WARNING: All changes in files are lost! Also when the
[!] is not used. It works like ":qall!" |:qall|,
except that Vim returns a non-zero exit code.
--- 229,245 ----
current window is used instead of the quickfix list.
*:cq* *:cquit*
! :cq[uit][!]
! :{N}cq[uit][!]
! :cq[uit][!] {N} Quit Vim with error code {N}. {N} defaults to
one.
! Useful when Vim is called from another program:
! e.g., a compiler will not compile the same file again,
! `git commit` will abort the committing process, `fc`
! (built-in for shells like bash and zsh) will not
! execute the command, etc. will not compile the same
! file again.
! {N} can also be zero, in which case Vim exits
! normally.
WARNING: All changes in files are lost! Also when the
[!] is not used. It works like ":qall!" |:qall|,
except that Vim returns a non-zero exit code.
*** ../vim-8.2.0094/src/ex_cmds.h 2019-12-16 17:10:30.291144418 +0100
--- src/ex_cmds.h 2020-01-06 21:39:32.417839253 +0100
***************
*** 407,413 ****
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
ADDR_OTHER),
EXCMD(CMD_cquit, "cquit", ex_cquit,
! EX_TRLBAR|EX_BANG,
ADDR_NONE),
EXCMD(CMD_crewind, "crewind", ex_cc,
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
--- 407,413 ----
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
ADDR_OTHER),
EXCMD(CMD_cquit, "cquit", ex_cquit,
! 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,
*** ../vim-8.2.0094/src/ex_docmd.c 2019-12-29 23:04:20.290639897 +0100
--- src/ex_docmd.c 2020-01-06 21:39:32.417839253 +0100
***************
*** 4920,4927 ****
static void
ex_cquit(exarg_T *eap UNUSED)
{
! getout(1); // this does not always pass on the exit code to the
Manx
! // compiler. why?
}
/*
--- 4920,4927 ----
static void
ex_cquit(exarg_T *eap UNUSED)
{
! // this does not always pass on the exit code to the Manx compiler. why?
! getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
}
/*
*** ../vim-8.2.0094/src/testdir/test_quickfix.vim 2019-12-06
21:09:53.000000000 +0100
--- src/testdir/test_quickfix.vim 2020-01-06 21:39:32.417839253 +0100
***************
*** 4674,4677 ****
--- 4674,4702 ----
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
*** ../vim-8.2.0094/src/version.c 2020-01-06 21:22:05.681590637 +0100
--- src/version.c 2020-01-06 21:41:00.493485354 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 95,
/**/
--
It is illegal for anyone to try and stop a child from playfully jumping over
puddles of water.
[real standing law in California, United States of America]
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202001062047.006KlqEC024846%40masaka.moolenaar.net.