mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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)
This commit is contained in:
@@ -229,8 +229,17 @@ processing a quickfix or location list command, it will be aborted.
|
|||||||
current window is used instead of the quickfix list.
|
current window is used instead of the quickfix list.
|
||||||
|
|
||||||
*:cq* *:cquit*
|
*:cq* *:cquit*
|
||||||
:cq[uit][!] Quit Vim with an error code, so that the compiler
|
:cq[uit][!]
|
||||||
will not compile the same file again.
|
:{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
|
WARNING: All changes in files are lost! Also when the
|
||||||
[!] is not used. It works like ":qall!" |:qall|,
|
[!] is not used. It works like ":qall!" |:qall|,
|
||||||
except that Vim returns a non-zero exit code.
|
except that Vim returns a non-zero exit code.
|
||||||
|
@@ -407,7 +407,7 @@ EXCMD(CMD_cpfile, "cpfile", ex_cnext,
|
|||||||
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
|
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
|
||||||
ADDR_OTHER),
|
ADDR_OTHER),
|
||||||
EXCMD(CMD_cquit, "cquit", ex_cquit,
|
EXCMD(CMD_cquit, "cquit", ex_cquit,
|
||||||
EX_TRLBAR|EX_BANG,
|
EX_RANGE|EX_COUNT|EX_ZEROR|EX_TRLBAR|EX_BANG,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_crewind, "crewind", ex_cc,
|
EXCMD(CMD_crewind, "crewind", ex_cc,
|
||||||
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
|
EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG,
|
||||||
|
@@ -4920,8 +4920,8 @@ ex_quit(exarg_T *eap)
|
|||||||
static void
|
static void
|
||||||
ex_cquit(exarg_T *eap UNUSED)
|
ex_cquit(exarg_T *eap UNUSED)
|
||||||
{
|
{
|
||||||
getout(1); // this does not always pass on the exit code to the Manx
|
// this does not always pass on the exit code to the Manx compiler. why?
|
||||||
// compiler. why?
|
getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -4674,4 +4674,29 @@ func Test_search_in_dirstack()
|
|||||||
call delete('Xtestdir', 'rf')
|
call delete('Xtestdir', 'rf')
|
||||||
endfunc
|
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: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -742,6 +742,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
95,
|
||||||
/**/
|
/**/
|
||||||
94,
|
94,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user