0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 7.4.831

Problem:    When expanding  on the command line and encountering an
            error, the command is executed anyway.
Solution:   Bail out when an error is detected.
This commit is contained in:
Bram Moolenaar
2015-08-25 13:57:04 +02:00
parent b341dda575
commit 3f188935ec
2 changed files with 11 additions and 4 deletions

View File

@@ -10875,6 +10875,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
char_u *p; char_u *p;
static int recursive = FALSE; static int recursive = FALSE;
int add_pat; int add_pat;
int retval = OK;
#if defined(FEAT_SEARCHPATH) #if defined(FEAT_SEARCHPATH)
int did_expand_in_path = FALSE; int did_expand_in_path = FALSE;
#endif #endif
@@ -10924,7 +10925,11 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
#ifdef VIM_BACKTICK #ifdef VIM_BACKTICK
if (vim_backtick(p)) if (vim_backtick(p))
{
add_pat = expand_backtick(&ga, p, flags); add_pat = expand_backtick(&ga, p, flags);
if (add_pat == -1)
retval = FAIL;
}
else else
#endif #endif
{ {
@@ -11013,7 +11018,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
recursive = FALSE; recursive = FALSE;
return (ga.ga_data != NULL) ? OK : FAIL; return (ga.ga_data != NULL) ? retval : FAIL;
} }
# ifdef VIM_BACKTICK # ifdef VIM_BACKTICK
@@ -11031,7 +11036,7 @@ vim_backtick(p)
/* /*
* Expand an item in `backticks` by executing it as a command. * Expand an item in `backticks` by executing it as a command.
* Currently only works when pat[] starts and ends with a `. * Currently only works when pat[] starts and ends with a `.
* Returns number of file names found. * Returns number of file names found, -1 if an error is encountered.
*/ */
static int static int
expand_backtick(gap, pat, flags) expand_backtick(gap, pat, flags)
@@ -11048,7 +11053,7 @@ expand_backtick(gap, pat, flags)
/* Create the command: lop off the backticks. */ /* Create the command: lop off the backticks. */
cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2); cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2);
if (cmd == NULL) if (cmd == NULL)
return 0; return -1;
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
if (*cmd == '=') /* `={expr}`: Expand expression */ if (*cmd == '=') /* `={expr}`: Expand expression */
@@ -11059,7 +11064,7 @@ expand_backtick(gap, pat, flags)
(flags & EW_SILENT) ? SHELL_SILENT : 0, NULL); (flags & EW_SILENT) ? SHELL_SILENT : 0, NULL);
vim_free(cmd); vim_free(cmd);
if (buffer == NULL) if (buffer == NULL)
return 0; return -1;
cmd = buffer; cmd = buffer;
while (*cmd != NUL) while (*cmd != NUL)

View File

@@ -741,6 +741,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 */
/**/
831,
/**/ /**/
830, 830,
/**/ /**/