I've discovered a bug, or at least a limitation, in the behavior
of the 'shellcmdflag' option: it does not allow for multiple flags
separated by spaces.
I encountered this problem when trying to set the option like this,
:set shellcmdflag=-O\ extglob\ -c
so that I could use :grep with bash's extended pattern matching
operators like this:
:grep pattern !(*Foo*)
That fails because Vim hands the contents of 'shellcmdflag' to bash
as a single argument instead of three.
The attached patch fixes this problem for Unix but not for other
operating systems because I have no way to test my changes in
environments other than Linux and Cygwin.
The patch is to Vim 7.3.189. I haven't updated that particular Vim
installation because I'm also trying to track down a race condition
in the handling of the termresponse and diff events and I don't want
to disturb the timing of those events.
Setting 'shellcmdflag' to "-ic" is not a satisfactory solution
because having bash source my ~/.bashrc when it's not in an
interactive environment causes other problems.
Regards,
Gary
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
*** - 2011-07-27 10:00:48.837165658 -0700
--- os_unix.c 2011-07-26 13:19:45.193369000 -0700
***************
*** 3816,3823 ****
--- 3816,3825 ----
int retval = -1;
char **argv = NULL;
int argc;
+ char *p_shcf_copy = NULL;
int i;
char_u *p;
+ char_u *s;
int inquote;
int pty_master_fd = -1; /* for pty's */
# ifdef FEAT_GUI
***************
*** 3876,3881 ****
--- 3878,3897 ----
}
if (argv == NULL)
{
+ /*
+ * Account for possible multiple args in p_shcf.
+ */
+ p = p_shcf;
+ while (*p)
+ {
+ while (*p && *p != ' ')
+ p++;
+ if (*p == NUL)
+ break;
+ ++argc;
+ p = skipwhite(p);
+ }
+
argv = (char **)alloc((unsigned)((argc + 4) * sizeof(char *)));
if (argv == NULL) /* out of memory */
goto error;
***************
*** 3885,3891 ****
{
if (extra_shell_arg != NULL)
argv[argc++] = (char *)extra_shell_arg;
! argv[argc++] = (char *)p_shcf;
argv[argc++] = (char *)cmd;
}
argv[argc] = NULL;
--- 3901,3921 ----
{
if (extra_shell_arg != NULL)
argv[argc++] = (char *)extra_shell_arg;
!
! p_shcf_copy = alloc((unsigned)STRLEN(p_shcf) + 1);
! if (p_shcf_copy == NULL) /* out of memory */
! goto error;
! s = p_shcf_copy;
! p = p_shcf;
! while (*p)
! {
! argv[argc++] = (char *)s;
! while (*p && *p != ' ' && *p != TAB)
! *s++ = *p++;
! *s++ = '\0';
! p = skipwhite(p);
! }
!
argv[argc++] = (char *)cmd;
}
argv[argc] = NULL;
***************
*** 4688,4693 ****
--- 4718,4724 ----
}
}
vim_free(argv);
+ vim_free(p_shcf_copy);
error:
if (!did_settmode)