vim-patch:7.4.831

Problem:    When expanding `=expr` on the command line and encountering an
            error, the command is executed anyway.
Solution:   Bail out when an error is detected.

3f188935ec
This commit is contained in:
watiko
2016-02-12 16:29:05 +09:00
parent fc51f86b72
commit c8561ecf26
2 changed files with 16 additions and 16 deletions

View File

@@ -1117,6 +1117,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
char_u *p; char_u *p;
static bool recursive = false; static bool recursive = false;
int add_pat; int add_pat;
bool retval = OK;
bool did_expand_in_path = false; bool did_expand_in_path = false;
/* /*
@@ -1158,12 +1159,13 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
add_pat = -1; add_pat = -1;
p = pat[i]; p = pat[i];
if (vim_backtick(p)) if (vim_backtick(p)) {
add_pat = expand_backtick(&ga, p, flags); add_pat = expand_backtick(&ga, p, flags);
else { if (add_pat == -1) {
/* retval = FAIL;
* First expand environment variables, "~/" and "~user/". }
*/ } else {
// First expand environment variables, "~/" and "~user/".
if (has_env_var(p) || *p == '~') { if (has_env_var(p) || *p == '~') {
p = expand_env_save_opt(p, true); p = expand_env_save_opt(p, true);
if (p == NULL) if (p == NULL)
@@ -1234,7 +1236,7 @@ int gen_expand_wildcards(int num_pat, char_u **pat, int *num_file,
recursive = false; recursive = false;
return (ga.ga_data != NULL) ? OK : FAIL; return (ga.ga_data != NULL) ? retval : FAIL;
} }
@@ -1246,13 +1248,10 @@ static int vim_backtick(char_u *p)
return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`'; return *p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`';
} }
/* // 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, -1 if an error is encountered.
* Returns number of file names found. static int expand_backtick(
*/
static int
expand_backtick (
garray_T *gap, garray_T *gap,
char_u *pat, char_u *pat,
int flags /* EW_* flags */ int flags /* EW_* flags */
@@ -1273,8 +1272,9 @@ expand_backtick (
buffer = get_cmd_output(cmd, NULL, buffer = get_cmd_output(cmd, NULL,
(flags & EW_SILENT) ? kShellOptSilent : 0, NULL); (flags & EW_SILENT) ? kShellOptSilent : 0, NULL);
xfree(cmd); xfree(cmd);
if (buffer == NULL) if (buffer == NULL) {
return 0; return -1;
}
cmd = buffer; cmd = buffer;
while (*cmd != NUL) { while (*cmd != NUL) {

View File

@@ -459,7 +459,7 @@ static int included_patches[] = {
834, 834,
833, 833,
// 832, // 832,
// 831, 831,
830, 830,
// 829 NA // 829 NA
828, 828,