Mercurial > vim
changeset 7036:5f00b8d7148f v7.4.831
commit https://github.com/vim/vim/commit/3f188935ec4db5117c4a64cc3f71219175624745
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 25 13:57:04 2015 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 25 Aug 2015 17:20:26 +0200 |
parents | 1804d2f6eb1d |
children | cbd20a957656 |
files | src/misc1.c src/version.c |
diffstat | 2 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/misc1.c +++ b/src/misc1.c @@ -10875,6 +10875,7 @@ gen_expand_wildcards(num_pat, pat, num_f char_u *p; static int recursive = FALSE; int add_pat; + int retval = OK; #if defined(FEAT_SEARCHPATH) int did_expand_in_path = FALSE; #endif @@ -10924,7 +10925,11 @@ gen_expand_wildcards(num_pat, pat, num_f #ifdef VIM_BACKTICK if (vim_backtick(p)) + { add_pat = expand_backtick(&ga, p, flags); + if (add_pat == -1) + retval = FAIL; + } else #endif { @@ -11013,7 +11018,7 @@ gen_expand_wildcards(num_pat, pat, num_f recursive = FALSE; - return (ga.ga_data != NULL) ? OK : FAIL; + return (ga.ga_data != NULL) ? retval : FAIL; } # ifdef VIM_BACKTICK @@ -11031,7 +11036,7 @@ vim_backtick(p) /* * Expand an item in `backticks` by executing it as a command. * 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 expand_backtick(gap, pat, flags) @@ -11048,7 +11053,7 @@ expand_backtick(gap, pat, flags) /* Create the command: lop off the backticks. */ cmd = vim_strnsave(pat + 1, (int)STRLEN(pat) - 2); if (cmd == NULL) - return 0; + return -1; #ifdef FEAT_EVAL if (*cmd == '=') /* `={expr}`: Expand expression */ @@ -11059,7 +11064,7 @@ expand_backtick(gap, pat, flags) (flags & EW_SILENT) ? SHELL_SILENT : 0, NULL); vim_free(cmd); if (buffer == NULL) - return 0; + return -1; cmd = buffer; while (*cmd != NUL)