To: vim-dev@vim.org Subject: patch 5.4.45 Fcc: outbox From: Bram Moolenaar ------------ This is a big one, even though it doesn't fix much. Part of the change is to cleanup the global variable expand_interactively. I thought of cleaning up expand_context too, but that would result in a lot of changes without fixing anything. I'll keep that for later. Patch 5.4.45 (also see 5.4.x8) Problem: When expand("$ASDF") fails, there is an error message. Solution: Remove the global expand_interactively. Pass a flag down to skip the error message. Also: expand("$ASDF") returns an empty string if $ASDF isn't set. Previously it returned "$ASDF" when 'shell' is "sh". Also: system() doesn't print an error when the command returns an error code. Files: many *** ../vim-5.4.44/src/edit.c Wed Aug 11 22:31:27 1999 --- src/edit.c Sun Aug 22 14:16:28 1999 *************** *** 1741,1747 **** p_scs = FALSE; set_reg_ic(pat); /* set reg_ic according to p_ic, p_scs and pat */ prog = vim_regcomp(pat, (int)p_magic); - expand_interactively = TRUE; while (buf != NULL && prog != NULL && *dict != NUL && !got_int && !completion_interrupted) { --- 1741,1746 ---- *************** *** 1754,1760 **** else { copy_option_part(&dict, buf, LSIZE, ","); ! if (expand_wildcards(1, &buf, &count, &files, EW_FILE) != OK) count = 0; } --- 1753,1760 ---- else { copy_option_part(&dict, buf, LSIZE, ","); ! if (expand_wildcards(1, &buf, &count, &files, ! EW_FILE|EW_SILENT) != OK) count = 0; } *************** *** 1804,1810 **** if (flags) break; } - expand_interactively = FALSE; p_scs = save_p_scs; vim_free(prog); vim_free(buf); --- 1804,1809 ---- *************** *** 2263,2271 **** break; case CTRL_X_FILES: - expand_interactively = TRUE; if (expand_wildcards(1, &complete_pat, &num_matches, &matches, ! EW_FILE|EW_DIR|EW_ADDSLASH) == OK) { int add_r = OK; int ldir = dir; --- 2262,2269 ---- break; case CTRL_X_FILES: if (expand_wildcards(1, &complete_pat, &num_matches, &matches, ! EW_FILE|EW_DIR|EW_ADDSLASH|EW_SILENT) == OK) { int add_r = OK; int ldir = dir; *************** *** 2279,2285 **** ldir = FORWARD; FreeWild(num_matches, matches); } - expand_interactively = FALSE; break; default: /* normal ^P/^N and ^X^L */ --- 2277,2282 ---- *************** *** 2799,2805 **** ; tmp_ptr += ++temp; temp = (int)complete_col - temp; ! complete_pat = addstar(tmp_ptr, temp); if (complete_pat == NULL) return FALSE; } --- 2796,2802 ---- ; tmp_ptr += ++temp; temp = (int)complete_col - temp; ! complete_pat = addstar(tmp_ptr, temp, EXPAND_FILES); if (complete_pat == NULL) return FALSE; } *** ../vim-5.4.44/src/eval.c Fri Aug 20 11:21:12 1999 --- src/eval.c Sun Aug 22 13:58:09 1999 *************** *** 2601,2607 **** char_u *s; int len; char_u *errormsg; ! int flags = WILD_LIST_NOTFOUND|WILD_USE_NL; retvar->var_type = VAR_STRING; s = get_var_string(&argvars[0]); --- 2601,2607 ---- char_u *s; int len; char_u *errormsg; ! int flags = WILD_SILENT|WILD_USE_NL; retvar->var_type = VAR_STRING; s = get_var_string(&argvars[0]); *************** *** 2613,2620 **** --- 2613,2623 ---- } else { + /* When the optional second argument is non-zero, don't remove matches + * for 'suffixes' and 'wildignore' */ if (argvars[1].var_type != VAR_UNKNOWN && get_var_number(&argvars[1])) flags |= WILD_KEEP_ALL; + expand_context = EXPAND_FILES; retvar->var_val.var_string = ExpandOne(s, NULL, flags, WILD_ALL); } } *************** *** 2787,2795 **** VAR argvars; VAR retvar; { retvar->var_type = VAR_STRING; retvar->var_val.var_string = ExpandOne(get_var_string(&argvars[0]), ! NULL, WILD_USE_NL, WILD_ALL); } /* --- 2790,2799 ---- VAR argvars; VAR retvar; { + expand_context = EXPAND_FILES; retvar->var_type = VAR_STRING; retvar->var_val.var_string = ExpandOne(get_var_string(&argvars[0]), ! NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL); } /* *************** *** 3805,3811 **** { char_u *p; ! p = get_cmd_output(get_var_string(&argvars[0])); #ifdef USE_CR /* translate into */ if (p != NULL) --- 3809,3815 ---- { char_u *p; ! p = get_cmd_output(get_var_string(&argvars[0]), SHELL_SILENT); #ifdef USE_CR /* translate into */ if (p != NULL) *** ../vim-5.4.44/src/ex_docmd.c Sat Aug 21 15:40:51 1999 --- src/ex_docmd.c Sun Aug 22 13:58:45 1999 *************** *** 3394,3400 **** * For other systems spaces are considered to be part * of the file name. * Only check here if there is no wildcard, otherwise ! * ExpandOne will check for errors. This allows * ":e `ls ve*.c`" on Unix. */ if (!has_wildcards) --- 3394,3400 ---- * For other systems spaces are considered to be part * of the file name. * Only check here if there is no wildcard, otherwise ! * ExpandOne() will check for errors. This allows * ":e `ls ve*.c`" on Unix. */ if (!has_wildcards) *************** *** 3451,3456 **** --- 3451,3457 ---- } else /* n == 2 */ { + expand_context = EXPAND_FILES; if ((p = ExpandOne(eap->arg, NULL, WILD_LIST_NOTFOUND|WILD_ADD_SLASH, WILD_EXPAND_FREE)) == NULL) *** ../vim-5.4.44/src/ex_getln.c Fri Aug 20 11:21:13 1999 --- src/ex_getln.c Sun Aug 22 14:27:06 1999 *************** *** 1904,1910 **** /* Caller can use the character as a normal char instead */ return FAIL; } - expand_interactively = TRUE; MSG_PUTS("..."); /* show that we are busy */ out_flush(); --- 1904,1909 ---- *************** *** 1924,1935 **** /* * Translate string into pattern and expand it. */ ! if ((p1 = addstar(&ccline.cmdbuff[i], oldlen)) == NULL) p2 = NULL; else { p2 = ExpandOne(p1, vim_strnsave(&ccline.cmdbuff[i], oldlen), ! WILD_HOME_REPLACE | WILD_ADD_SLASH | options, type); vim_free(p1); /* longest match: make sure it is not shorter (happens with :help */ if (p2 != NULL && type == WILD_LONGEST) --- 1923,1935 ---- /* * Translate string into pattern and expand it. */ ! if ((p1 = addstar(&ccline.cmdbuff[i], oldlen, expand_context)) == NULL) p2 = NULL; else { p2 = ExpandOne(p1, vim_strnsave(&ccline.cmdbuff[i], oldlen), ! WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE ! |options, type); vim_free(p1); /* longest match: make sure it is not shorter (happens with :help */ if (p2 != NULL && type == WILD_LONGEST) *************** *** 1970,1976 **** vim_free(p2); redrawcmd(); - expand_interactively = FALSE; /* reset for next call */ /* When expanding a ":map" command and no matches are found, assume that * the key is supposed to be inserted literally */ --- 1970,1975 ---- *************** *** 2005,2010 **** --- 2004,2013 ---- * options = WILD_NO_BEEP: Don't beep for multiple matches * options = WILD_ADD_SLASH: add a slash after directory names * options = WILD_KEEP_ALL: don't remove 'wildignore' entries + * options = WILD_SILENT: don't print warning messages + * options = WILD_ESCAPE: put backslash before special chars + * + * The global variable expand_context must have been set! */ char_u * ExpandOne(str, orig, options, mode) *************** *** 2096,2108 **** * are wildcards, the real problem is that there was no match, * causing the pattern to be added, which has illegal characters. */ ! if (!expand_interactively && (options & WILD_LIST_NOTFOUND)) emsg2(e_nomatch2, str); #endif } else if (cmd_numfiles == 0) { ! if (!expand_interactively) emsg2(e_nomatch2, str); } else --- 2099,2111 ---- * are wildcards, the real problem is that there was no match, * causing the pattern to be added, which has illegal characters. */ ! if (!(options & WILD_SILENT) && (options & WILD_LIST_NOTFOUND)) emsg2(e_nomatch2, str); #endif } else if (cmd_numfiles == 0) { ! if (!(options & WILD_SILENT)) emsg2(e_nomatch2, str); } else *************** *** 2117,2123 **** * Insert backslashes into a file name before a space, \, %, # and * wildmatch characters, except '~'. */ ! if (expand_interactively && (expand_context == EXPAND_FILES || expand_context == EXPAND_BUFFERS || expand_context == EXPAND_DIRECTORIES)) --- 2120,2126 ---- * Insert backslashes into a file name before a space, \, %, # and * wildmatch characters, except '~'. */ ! if ((options & WILD_ESCAPE) && (expand_context == EXPAND_FILES || expand_context == EXPAND_BUFFERS || expand_context == EXPAND_DIRECTORIES)) *************** *** 2172,2179 **** non_suf_match = cmd_numfiles; else non_suf_match = 1; ! if ((!expand_interactively ! || expand_context == EXPAND_FILES || expand_context == EXPAND_DIRECTORIES) && cmd_numfiles > 1) /* more than one match; check suffix */ { --- 2175,2181 ---- non_suf_match = cmd_numfiles; else non_suf_match = 1; ! if ((expand_context == EXPAND_FILES || expand_context == EXPAND_DIRECTORIES) && cmd_numfiles > 1) /* more than one match; check suffix */ { *************** *** 2193,2199 **** * together. Don't really want to wait for this message * (and possibly have to hit return to continue!). */ ! if (!expand_interactively) emsg(e_toomany); else if (!(options & WILD_NO_BEEP)) beep_flush(); --- 2195,2201 ---- * together. Don't really want to wait for this message * (and possibly have to hit return to continue!). */ ! if (!(options & WILD_SILENT)) emsg(e_toomany); else if (!(options & WILD_NO_BEEP)) beep_flush(); *************** *** 2328,2347 **** /* Caller can use the character as a normal char instead */ return FAIL; } - expand_interactively = TRUE; /* add star to file name, or convert to regexp if not exp. files. */ file_str = addstar(expand_pattern, ! (int)(ccline.cmdbuff + ccline.cmdpos - expand_pattern)); if (file_str == NULL) - { - expand_interactively = FALSE; return OK; - } /* find all files that match the description */ if (ExpandFromContext(file_str, &num_files, &files_found, FALSE, ! WILD_ADD_SLASH) == FAIL) { num_files = 0; files_found = (char_u **)""; --- 2330,2346 ---- /* Caller can use the character as a normal char instead */ return FAIL; } /* add star to file name, or convert to regexp if not exp. files. */ file_str = addstar(expand_pattern, ! (int)(ccline.cmdbuff + ccline.cmdpos - expand_pattern), ! expand_context); if (file_str == NULL) return OK; /* find all files that match the description */ if (ExpandFromContext(file_str, &num_files, &files_found, FALSE, ! WILD_ADD_SLASH|WILD_SILENT) == FAIL) { num_files = 0; files_found = (char_u **)""; *************** *** 2471,2500 **** FreeWild(num_files, files_found); } - expand_interactively = FALSE; return OK; } /* * Prepare a string for expansion. ! * When expanding file names: The string will be used with expand_wildcards(). * Copy the file name into allocated memory and add a '*' at the end. ! * When expanding other names: The string will be used with regcomp(). Copy * the name into allocated memory and add ".*" at the end. */ char_u * ! addstar(fname, len) char_u *fname; int len; { char_u *retval; int i, j; int new_len; char_u *tail; ! if (expand_interactively ! && expand_context != EXPAND_FILES ! && expand_context != EXPAND_DIRECTORIES) { /* * Matching will be done internally (on something other than files). --- 2470,2497 ---- FreeWild(num_files, files_found); } return OK; } /* * Prepare a string for expansion. ! * When expanding file names: The string will be used with expand_wildcards(). * Copy the file name into allocated memory and add a '*' at the end. ! * When expanding other names: The string will be used with regcomp(). Copy * the name into allocated memory and add ".*" at the end. */ char_u * ! addstar(fname, len, context) char_u *fname; int len; + int context; /* EXPAND_FILES etc. */ { char_u *retval; int i, j; int new_len; char_u *tail; ! if (context != EXPAND_FILES && context != EXPAND_DIRECTORIES) { /* * Matching will be done internally (on something other than files). *************** *** 2503,2509 **** */ /* for help tags the translation is done in find_help_tags() */ ! if (expand_context == EXPAND_HELP) retval = vim_strnsave(fname, len); else { --- 2500,2506 ---- */ /* for help tags the translation is done in find_help_tags() */ ! if (context == EXPAND_HELP) retval = vim_strnsave(fname, len); else { *************** *** 2515,2521 **** '~' needs to be replaced by "\~" */ /* Buffer names are like file names. "." should be literal */ ! if (expand_context == EXPAND_BUFFERS && fname[i] == '.') new_len++; /* "." becomes "\." */ } retval = alloc(new_len); --- 2512,2518 ---- '~' needs to be replaced by "\~" */ /* Buffer names are like file names. "." should be literal */ ! if (context == EXPAND_BUFFERS && fname[i] == '.') new_len++; /* "." becomes "\." */ } retval = alloc(new_len); *************** *** 2536,2542 **** break; case '?': retval[j] = '.'; continue; ! case '.': if (expand_context == EXPAND_BUFFERS) retval[j++] = '\\'; break; } --- 2533,2539 ---- break; case '?': retval[j] = '.'; continue; ! case '.': if (context == EXPAND_BUFFERS) retval[j++] = '\\'; break; } *************** *** 2679,2686 **** flags |= EW_ADDSLASH; if (options & WILD_KEEP_ALL) flags |= EW_KEEPALL; ! if (!expand_interactively || expand_context == EXPAND_FILES) { /* * Expand file names. --- 2676,2685 ---- flags |= EW_ADDSLASH; if (options & WILD_KEEP_ALL) flags |= EW_KEEPALL; + if (options & WILD_SILENT) + flags |= EW_SILENT; ! if (expand_context == EXPAND_FILES) { /* * Expand file names. *** ../vim-5.4.44/src/memline.c Tue Aug 10 16:09:34 1999 --- src/memline.c Sun Aug 22 13:35:25 1999 *************** *** 1169,1175 **** msg((char_u *)"Swap files found:"); msg_putchar('\n'); } - expand_interactively = TRUE; /* * Do the loop for every directory in 'directory'. --- 1169,1174 ---- *************** *** 1273,1279 **** if (num_names == 0) num_files = 0; else if (expand_wildcards(num_names, names, &num_files, &files, ! EW_FILE) == FAIL) num_files = 0; /* --- 1272,1278 ---- if (num_names == 0) num_files = 0; else if (expand_wildcards(num_names, names, &num_files, &files, ! EW_FILE|EW_SILENT) == FAIL) num_files = 0; /* *************** *** 1372,1378 **** FreeWild(num_files, files); } vim_free(dir_name); - expand_interactively = FALSE; return file_count; } --- 1371,1376 ---- *************** *** 3627,3634 **** # endif (char_u *)"&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Delete it", 1)) { - /* there are some messy ways to avoid the hit-return - * message here... */ case 1: buf->b_p_ro = TRUE; break; --- 3625,3630 ---- *** ../vim-5.4.44/src/misc1.c Wed Aug 18 10:54:13 1999 --- src/misc1.c Sun Aug 22 14:55:04 1999 *************** *** 2343,2349 **** if (var == NULL) # endif { ! var = ExpandOne(dst, NULL, WILD_ADD_SLASH, WILD_EXPAND_FREE); mustfree = TRUE; } --- 2344,2351 ---- if (var == NULL) # endif { ! expand_context = EXPAND_FILES; ! var = ExpandOne(dst, NULL, WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); mustfree = TRUE; } *************** *** 5210,5225 **** */ int expand_wildcards(num_pat, pat, num_file, file, flags) ! int num_pat; /* number of input patterns */ ! char_u **pat; /* array of input patterns */ ! int *num_file; /* resulting number of files */ ! char_u ***file; /* array of resulting files */ ! int flags; /* EW_DIR, etc. */ { int retval; int i, j; char_u *p; ! int non_suf_match; /* number without matching suffix */ #ifdef WILDIGNORE char_u buf[100]; char_u *ffname; --- 5212,5227 ---- */ int expand_wildcards(num_pat, pat, num_file, file, flags) ! int num_pat; /* number of input patterns */ ! char_u **pat; /* array of input patterns */ ! int *num_file; /* resulting number of files */ ! char_u ***file; /* array of resulting files */ ! int flags; /* EW_DIR, etc. */ { int retval; int i, j; char_u *p; ! int non_suf_match; /* number without matching suffix */ #ifdef WILDIGNORE char_u buf[100]; char_u *ffname; *************** *** 5329,5334 **** --- 5331,5341 ---- } #ifndef NO_EXPANDPATH + + # ifdef VIM_BACKTICK + static int expand_backtick __ARGS((struct growarray *gap, char_u *pat, int flags)); + # endif + /* * Generic wildcard expansion code. * *************** *** 5346,5352 **** char_u **pat; /* array of input patterns */ int *num_file; /* resulting number of files */ char_u ***file; /* array of resulting files */ ! int flags; /* EW_DIR, EW_FILE, EW_NOTFOUND, EW_ADDSLASH */ { int i; struct growarray ga; --- 5353,5359 ---- char_u **pat; /* array of input patterns */ int *num_file; /* resulting number of files */ char_u ***file; /* array of resulting files */ ! int flags; /* EW_* flags */ { int i; struct growarray ga; *************** *** 5456,5472 **** return (ga.ga_data != NULL) ? OK : FAIL; } ! #if defined(VIM_BACKTICK) || defined(PROTO) /* * Expand an item in `backticks` by executing it as a command. * Currently only works when pat[] starts and ends with a `. */ ! int expand_backtick(gap, pat, flags) struct growarray *gap; char_u *pat; ! int flags; { char_u *p; char_u *cmd; --- 5463,5479 ---- return (ga.ga_data != NULL) ? OK : FAIL; } ! # ifdef VIM_BACKTICK /* * Expand an item in `backticks` by executing it as a command. * Currently only works when pat[] starts and ends with a `. */ ! static int expand_backtick(gap, pat, flags) struct growarray *gap; char_u *pat; ! int flags; /* EW_* flags */ { char_u *p; char_u *cmd; *************** *** 5479,5485 **** if (cmd == NULL) return 0; ! buffer = get_cmd_output(cmd); vim_free(cmd); if (buffer == NULL) return 0; --- 5486,5492 ---- if (cmd == NULL) return 0; ! buffer = get_cmd_output(cmd, (flags & EW_SILENT) ? SHELL_SILENT : 0); vim_free(cmd); if (buffer == NULL) return 0; *************** *** 5508,5514 **** vim_free(buffer); return cnt; } ! #endif /* * Add a file to a file list. Accepted flags: --- 5515,5521 ---- vim_free(buffer); return cnt; } ! # endif /* VIM_BACKTICK */ /* * Add a file to a file list. Accepted flags: *************** *** 5578,5585 **** * Returns an allocated string, or NULL for error. */ char_u * ! get_cmd_output(cmd) char_u *cmd; { char_u *tempname; char_u *command; --- 5585,5593 ---- * Returns an allocated string, or NULL for error. */ char_u * ! get_cmd_output(cmd, flags) char_u *cmd; + int flags; /* can be SHELL_SILENT */ { char_u *tempname; char_u *command; *************** *** 5603,5609 **** /* * Call the shell to execute the command (errors are ignored). */ ! call_shell(command, SHELL_DOOUT | SHELL_EXPAND); vim_free(command); /* --- 5611,5617 ---- /* * Call the shell to execute the command (errors are ignored). */ ! call_shell(command, SHELL_DOOUT | SHELL_EXPAND | flags); vim_free(command); /* *** ../vim-5.4.44/src/os_unix.c Tue Aug 17 10:24:26 1999 --- src/os_unix.c Sun Aug 22 14:57:24 1999 *************** *** 2013,2022 **** int mch_call_shell(cmd, options) ! char_u *cmd; ! int options; /* SHELL_FILTER if called by do_filter() */ ! /* SHELL_COOKED if term needs cooked mode */ ! /* SHELL_EXPAND if called by mch_expand_wildcards() */ { #ifdef USE_SYSTEM /* use system() to start the shell: simple but slow */ --- 2013,2020 ---- int mch_call_shell(cmd, options) ! char_u *cmd; ! int options; /* SHELL_*, see vim.h */ { #ifdef USE_SYSTEM /* use system() to start the shell: simple but slow */ *************** *** 2087,2093 **** MSG_PUTS("\nCannot execute shell sh\n"); } #endif /* __EMX__ */ ! else if (x && !expand_interactively) { msg_putchar('\n'); msg_outnum((long)x); --- 2085,2091 ---- MSG_PUTS("\nCannot execute shell sh\n"); } #endif /* __EMX__ */ ! else if (x && !(options & SHELL_SILENT)) { msg_putchar('\n'); msg_outnum((long)x); *************** *** 2632,2638 **** msg_outtrans(p_sh); msg_putchar('\n'); } ! else if (!expand_interactively) { msg_putchar('\n'); msg_outnum((long)retval); --- 2630,2636 ---- msg_outtrans(p_sh); msg_putchar('\n'); } ! else if (!(options & SHELL_SILENT)) { msg_putchar('\n'); msg_outnum((long)retval); *************** *** 2967,2973 **** mch_expandpath(gap, path, flags) struct growarray *gap; char_u *path; ! int flags; { return unix_expandpath(gap, path, 0, flags); } --- 2965,2971 ---- mch_expandpath(gap, path, flags) struct growarray *gap; char_u *path; ! int flags; /* EW_* flags */ { return unix_expandpath(gap, path, 0, flags); } *************** *** 2977,2983 **** struct growarray *gap; char_u *path; int wildoff; ! int flags; { char_u *buf; char_u *path_end; --- 2975,2981 ---- struct growarray *gap; char_u *path; int wildoff; ! int flags; /* EW_* flags */ { char_u *buf; char_u *path_end; *************** *** 3129,3150 **** /* ARGSUSED */ int mch_expand_wildcards(num_pat, pat, num_file, file, flags) ! int num_pat; ! char_u **pat; ! int *num_file; ! char_u ***file; ! int flags; { ! int i; ! size_t len; ! char_u *p; ! int dir; #ifdef __EMX__ # define EXPL_ALLOC_INC 16 ! char_u **expl_files; ! size_t files_alloced, files_free; ! char_u *buf; ! int has_wildcard; *num_file = 0; /* default: no files found */ files_alloced = EXPL_ALLOC_INC; /* how much space is allocated */ --- 3127,3148 ---- /* ARGSUSED */ int mch_expand_wildcards(num_pat, pat, num_file, file, flags) ! int num_pat; ! char_u **pat; ! int *num_file; ! char_u ***file; ! int flags; /* EW_* flags */ { ! int i; ! size_t len; ! char_u *p; ! int dir; #ifdef __EMX__ # define EXPL_ALLOC_INC 16 ! char_u **expl_files; ! size_t files_alloced, files_free; ! char_u *buf; ! int has_wildcard; *num_file = 0; /* default: no files found */ files_alloced = EXPL_ALLOC_INC; /* how much space is allocated */ *************** *** 3348,3354 **** STRCAT(command, pat[i]); #endif } ! if (expand_interactively) show_shell_mess = FALSE; if (ampersent) STRCAT(command, "&"); /* put the '&' back after the --- 3346,3352 ---- STRCAT(command, pat[i]); #endif } ! if (flags & EW_SILENT) show_shell_mess = FALSE; if (ampersent) STRCAT(command, "&"); /* put the '&' back after the *************** *** 3370,3376 **** else if (shell_style == STYLE_GLOB && !have_dollars(num_pat, pat)) extra_shell_arg = (char_u *)"-f"; /* Use csh fast option */ ! i = call_shell(command, SHELL_EXPAND); /* execute it */ /* When running in the background, give it some time to create the temp * file, but don't wait for it to finish. */ --- 3368,3378 ---- else if (shell_style == STYLE_GLOB && !have_dollars(num_pat, pat)) extra_shell_arg = (char_u *)"-f"; /* Use csh fast option */ ! /* ! * execute the shell command ! */ ! i = call_shell(command, ! SHELL_EXPAND | ((flags & EW_SILENT) ? SHELL_SILENT : 0)); /* When running in the background, give it some time to create the temp * file, but don't wait for it to finish. */ *************** *** 3391,3397 **** * from the shell, so screen may still get messed up -- webb. */ #ifndef USE_SYSTEM ! if (!expand_interactively) #endif { must_redraw = CLEAR; /* probably messed up screen */ --- 3393,3399 ---- * from the shell, so screen may still get messed up -- webb. */ #ifndef USE_SYSTEM ! if (!(flags & EW_SILENT)) #endif { must_redraw = CLEAR; /* probably messed up screen */ *************** *** 3550,3556 **** for (j = 0, i = 0; i < *num_file; ++i) { /* Require the files to exist. Helps when using /bin/sh */ ! if (expand_interactively && mch_getperm((*file)[i]) < 0) continue; /* check if this entry should be included */ --- 3552,3558 ---- for (j = 0, i = 0; i < *num_file; ++i) { /* Require the files to exist. Helps when using /bin/sh */ ! if (!(flags & EW_NOTFOUND) && mch_getperm((*file)[i]) < 0) continue; /* check if this entry should be included */ *** ../vim-5.4.44/src/proto/ex_getln.pro Tue Aug 10 16:10:35 1999 --- src/proto/ex_getln.pro Sun Aug 22 13:52:55 1999 *************** *** 11,17 **** void gotocmdline __ARGS((int clr)); char_u *ExpandOne __ARGS((char_u *str, char_u *orig, int options, int mode)); void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files)); ! char_u *addstar __ARGS((char_u *fname, int len)); int ExpandGeneric __ARGS((vim_regexp *prog, int *num_file, char_u ***file, char_u *((*func)(int)))); int get_histtype __ARGS((char_u *name)); void add_to_history __ARGS((int histype, char_u *new_entry, int in_map)); --- 11,17 ---- void gotocmdline __ARGS((int clr)); char_u *ExpandOne __ARGS((char_u *str, char_u *orig, int options, int mode)); void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files)); ! char_u *addstar __ARGS((char_u *fname, int len, int context)); int ExpandGeneric __ARGS((vim_regexp *prog, int *num_file, char_u ***file, char_u *((*func)(int)))); int get_histtype __ARGS((char_u *name)); void add_to_history __ARGS((int histype, char_u *new_entry, int in_map)); *** ../vim-5.4.44/src/proto/misc1.pro Sun Jul 25 13:08:32 1999 --- src/proto/misc1.pro Sat Aug 21 20:49:59 1999 *************** *** 59,66 **** void line_breakcheck __ARGS((void)); int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)); int match_suffix __ARGS((char_u *fname)); - int expand_backtick __ARGS((struct growarray *gap, char_u *pat, int flags)); void addfile __ARGS((struct growarray *gap, char_u *f, int flags)); ! char_u *get_cmd_output __ARGS((char_u *cmd)); void FreeWild __ARGS((int num, char_u **file)); int goto_im __ARGS((void)); --- 59,65 ---- void line_breakcheck __ARGS((void)); int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)); int match_suffix __ARGS((char_u *fname)); void addfile __ARGS((struct growarray *gap, char_u *f, int flags)); ! char_u *get_cmd_output __ARGS((char_u *cmd, int flags)); void FreeWild __ARGS((int num, char_u **file)); int goto_im __ARGS((void)); *** ../vim-5.4.44/src/tag.c Thu Jul 15 20:34:12 1999 --- src/tag.c Sun Aug 22 14:02:19 1999 *************** *** 2262,2269 **** /* * expand file name (for environment variables) */ ! expanded_fname = ExpandOne((char_u *)fname, NULL, WILD_LIST_NOTFOUND, ! WILD_EXPAND_FREE); if (expanded_fname != NULL) fname = expanded_fname; --- 2262,2270 ---- /* * expand file name (for environment variables) */ ! expand_context = EXPAND_FILES; ! expanded_fname = ExpandOne((char_u *)fname, NULL, ! WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); if (expanded_fname != NULL) fname = expanded_fname; *** ../vim-5.4.44/src/vim.h Mon May 31 22:15:00 1999 --- src/vim.h Sun Aug 22 14:34:29 1999 *************** *** 339,348 **** #define WILD_LIST_NOTFOUND 1 #define WILD_HOME_REPLACE 2 ! #define WILD_USE_NL 4 /* separate names with '\n' */ ! #define WILD_NO_BEEP 8 /* don't beep for multiple matches */ ! #define WILD_ADD_SLASH 16 /* add slash after directory name */ ! #define WILD_KEEP_ALL 32 /* keep all matches */ /* Flags for expand_wildcards() */ #define EW_DIR 1 /* include directory names */ --- 339,350 ---- #define WILD_LIST_NOTFOUND 1 #define WILD_HOME_REPLACE 2 ! #define WILD_USE_NL 4 ! #define WILD_NO_BEEP 8 ! #define WILD_ADD_SLASH 16 ! #define WILD_KEEP_ALL 32 ! #define WILD_SILENT 64 ! #define WILD_ESCAPE 128 /* Flags for expand_wildcards() */ #define EW_DIR 1 /* include directory names */ *************** *** 350,355 **** --- 352,361 ---- #define EW_NOTFOUND 4 /* include not found names */ #define EW_ADDSLASH 8 /* append slash to directory name */ #define EW_KEEPALL 16 /* keep all matches */ + #define EW_SILENT 32 /* don't print "1 returned" from shell */ + /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND + * is used when executing commands and EW_SILENT for interactive expanding. */ + #ifdef NO_EXPANDPATH # define gen_expand_wildcards mch_expand_wildcards #endif *************** *** 403,408 **** --- 409,415 ---- #define SHELL_EXPAND 2 /* expanding wildcards */ #define SHELL_COOKED 4 /* set term to cooked mode */ #define SHELL_DOOUT 8 /* redirecting output */ + #define SHELL_SILENT 16 /* don't print error returned by command */ /* Values for readfile() flags */ #define READ_NEW 0x01 /* read a file into a new buffer */ *** ../vim-5.4.44/src/window.c Tue Jul 13 10:24:22 1999 --- src/window.c Sun Aug 22 13:35:31 1999 *************** *** 2143,2152 **** file_name[len] = NUL; } - ++expand_interactively; expand_wildcards(1, &file_name, &nFiles, &ppFiles, ! EW_FILE|EW_DIR|EW_ADDSLASH); ! --expand_interactively; if (!*rest_of_wildcards) { --- 2143,2150 ---- file_name[len] = NUL; } expand_wildcards(1, &file_name, &nFiles, &ppFiles, ! EW_FILE|EW_DIR|EW_ADDSLASH|EW_SILENT); if (!*rest_of_wildcards) { *** ../vim-5.4.44/runtime/doc/eval.txt Wed Aug 18 13:05:54 1999 --- runtime/doc/eval.txt Sun Aug 22 13:20:42 1999 *************** *** 1,4 **** ! *eval.txt* For Vim version 5.4. Last change: 1999 Jul 09 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 5.4. Last change: 1999 Aug 22 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 334,339 **** --- 334,350 ---- The String value of any environment variable. When it is not defined, the result is an empty string. + *expr-env-expand* + Note that there is a difference between using $VAR directly and using + expand("$VAR"). Using it directly will only expand environment variables that + are known inside the current Vim session. Using expand() will first try using + the environment variables known inside the current Vim session. If that + fails, a shell will be used to expand the variable. This can be slow, but it + does expand all variables that the shell knows about. Example: + > echo $version + > echo expand("$version") + The first one probably doesn't echo anything, the second echoes the $version + variable (if you shell supports it). internal variable *expr-variable* *************** *** 721,727 **** caused problems when a file name contains a space] If the expansion fails, the result is an empty string. A name ! for a non-existing file is included anyway. When {expr} starts with '%', '#' or '<', the expansion is done like for the |cmdline-special| variables with their associated --- 732,738 ---- caused problems when a file name contains a space] If the expansion fails, the result is an empty string. A name ! for a non-existing file is not included. When {expr} starts with '%', '#' or '<', the expansion is done like for the |cmdline-special| variables with their associated *************** *** 750,755 **** --- 761,771 ---- > :let doesntwork = expand("%:h.bak") Use this: > :let doeswork = expand("%:h") . ".bak" + Also note that expanding "" and others only returns the + referenced file name without further expansion. If "" + is "~/.cshrc", you need to do another expand() to have the + "~/" expanded into the path of the home directory: + > :echo expand(expand("")) There cannot be white space between the variables and the following modifier. The |fnamemodify()| function can be used *************** *** 763,769 **** When {expr} does not start with '%', '#' or '<', it is expanded like a file name is expanded on the command line. 'suffixes' and 'wildignore' are used, unless the optional ! second argument is given and it is non-zero. See |glob()| for finding existing files. See |system()| for getting the raw output of an external command. --- 779,789 ---- When {expr} does not start with '%', '#' or '<', it is expanded like a file name is expanded on the command line. 'suffixes' and 'wildignore' are used, unless the optional ! {flag} argument is given and it is non-zero. ! ! Expand() can also be used to expand variables and environment ! variables that are only known in a shell. But this can be ! slow, because a shell must be started. See |expr-env-expand|. See |glob()| for finding existing files. See |system()| for getting the raw output of an external command. *** ../vim-5.4.44/src/version.h Sun Aug 22 14:14:53 1999 --- src/version.h Sun Aug 22 16:52:21 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 44 ! #define VIM_VERSION_PATCHLEVEL_STR "44" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 45 ! #define VIM_VERSION_PATCHLEVEL_STR "45" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.44" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.44 (1999 Aug 21)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.44 (1999 Aug 21, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.45" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.45 (1999 Aug 22)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.45 (1999 Aug 22, compiled " -- hundred-and-one symptoms of being an internet addict: 185. You order fast food over the Internet --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /