073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.276
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.276
073263
Problem:    The fish shell is not supported.
073263
Solution:   Use begin/end instead of () for fish. (Andy Russell)
073263
Files:	    src/ex_cmds.c, src/misc1.c, src/option.c, src/proto/misc1.pro
073263
073263
073263
*** ../vim-7.4.275/src/ex_cmds.c	2014-05-07 14:38:41.129091709 +0200
073263
--- src/ex_cmds.c	2014-05-07 15:09:57.797108136 +0200
073263
***************
073263
*** 1551,1558 ****
073263
  {
073263
      char_u	*buf;
073263
      long_u	len;
073263
  
073263
!     len = (long_u)STRLEN(cmd) + 3;			/* "()" + NUL */
073263
      if (itmp != NULL)
073263
  	len += (long_u)STRLEN(itmp) + 9;		/* " { < " + " } " */
073263
      if (otmp != NULL)
073263
--- 1551,1566 ----
073263
  {
073263
      char_u	*buf;
073263
      long_u	len;
073263
+     int		is_fish_shell;
073263
  
073263
! #if (defined(UNIX) && !defined(ARCHIE)) || defined(OS2)
073263
!     /* Account for fish's different syntax for subshells */
073263
!     is_fish_shell = (fnamecmp(get_isolated_shell_name(), "fish") == 0);
073263
!     if (is_fish_shell)
073263
! 	len = (long_u)STRLEN(cmd) + 13;		/* "begin; " + "; end" + NUL */
073263
!     else
073263
! #endif
073263
! 	len = (long_u)STRLEN(cmd) + 3;			/* "()" + NUL */
073263
      if (itmp != NULL)
073263
  	len += (long_u)STRLEN(itmp) + 9;		/* " { < " + " } " */
073263
      if (otmp != NULL)
073263
***************
073263
*** 1567,1573 ****
073263
       * redirecting input and/or output.
073263
       */
073263
      if (itmp != NULL || otmp != NULL)
073263
! 	vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
073263
      else
073263
  	STRCPY(buf, cmd);
073263
      if (itmp != NULL)
073263
--- 1575,1586 ----
073263
       * redirecting input and/or output.
073263
       */
073263
      if (itmp != NULL || otmp != NULL)
073263
!     {
073263
! 	if (is_fish_shell)
073263
! 	    vim_snprintf((char *)buf, len, "begin; %s; end", (char *)cmd);
073263
! 	else
073263
! 	    vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
073263
!     }
073263
      else
073263
  	STRCPY(buf, cmd);
073263
      if (itmp != NULL)
073263
***************
073263
*** 1577,1583 ****
073263
      }
073263
  #else
073263
      /*
073263
!      * for shells that don't understand braces around commands, at least allow
073263
       * the use of commands in a pipe.
073263
       */
073263
      STRCPY(buf, cmd);
073263
--- 1590,1596 ----
073263
      }
073263
  #else
073263
      /*
073263
!      * For shells that don't understand braces around commands, at least allow
073263
       * the use of commands in a pipe.
073263
       */
073263
      STRCPY(buf, cmd);
073263
***************
073263
*** 4315,4321 ****
073263
      pos_T	old_cursor = curwin->w_cursor;
073263
      int		start_nsubs;
073263
  #ifdef FEAT_EVAL
073263
!     int         save_ma = 0;
073263
  #endif
073263
  
073263
      cmd = eap->arg;
073263
--- 4328,4334 ----
073263
      pos_T	old_cursor = curwin->w_cursor;
073263
      int		start_nsubs;
073263
  #ifdef FEAT_EVAL
073263
!     int		save_ma = 0;
073263
  #endif
073263
  
073263
      cmd = eap->arg;
073263
***************
073263
*** 5986,5992 ****
073263
  			       "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
073263
  			       "\\[count]", "\\[quotex]", "\\[range]",
073263
  			       "\\[pattern]", "\\\\bar", "/\\\\%\\$",
073263
!                                "s/\\\\\\~", "s/\\\\U", "s/\\\\L",
073263
  			       "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
073263
      int flags;
073263
  
073263
--- 5999,6005 ----
073263
  			       "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
073263
  			       "\\[count]", "\\[quotex]", "\\[range]",
073263
  			       "\\[pattern]", "\\\\bar", "/\\\\%\\$",
073263
! 			       "s/\\\\\\~", "s/\\\\U", "s/\\\\L",
073263
  			       "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
073263
      int flags;
073263
  
073263
***************
073263
*** 6026,6032 ****
073263
  	  /* Replace:
073263
  	   * "[:...:]" with "\[:...:]"
073263
  	   * "[++...]" with "\[++...]"
073263
! 	   * "\{" with "\\{"               -- matching "} \}"
073263
  	   */
073263
  	    if ((arg[0] == '[' && (arg[1] == ':'
073263
  			 || (arg[1] == '+' && arg[2] == '+')))
073263
--- 6039,6045 ----
073263
  	  /* Replace:
073263
  	   * "[:...:]" with "\[:...:]"
073263
  	   * "[++...]" with "\[++...]"
073263
! 	   * "\{" with "\\{"		   -- matching "} \}"
073263
  	   */
073263
  	    if ((arg[0] == '[' && (arg[1] == ':'
073263
  			 || (arg[1] == '+' && arg[2] == '+')))
073263
*** ../vim-7.4.275/src/misc1.c	2014-04-05 19:44:36.903160723 +0200
073263
--- src/misc1.c	2014-05-07 15:04:25.921105231 +0200
073263
***************
073263
*** 1405,1411 ****
073263
  #ifdef FEAT_SMARTINDENT
073263
  	if (did_si)
073263
  	{
073263
! 	    int        sw = (int)get_sw_value(curbuf);
073263
  
073263
  	    if (p_sr)
073263
  		newindent -= newindent % sw;
073263
--- 1405,1411 ----
073263
  #ifdef FEAT_SMARTINDENT
073263
  	if (did_si)
073263
  	{
073263
! 	    int sw = (int)get_sw_value(curbuf);
073263
  
073263
  	    if (p_sr)
073263
  		newindent -= newindent % sw;
073263
***************
073263
*** 10896,10898 ****
073263
--- 10896,10936 ----
073263
  {
073263
      return (p_im && stuff_empty() && typebuf_typed());
073263
  }
073263
+ 
073263
+ /*
073263
+  * Returns the isolated name of the shell:
073263
+  * - Skip beyond any path.  E.g., "/usr/bin/csh -f" -> "csh -f".
073263
+  * - Remove any argument.  E.g., "csh -f" -> "csh".
073263
+  * But don't allow a space in the path, so that this works:
073263
+  *   "/usr/bin/csh --rcfile ~/.cshrc"
073263
+  * But don't do that for Windows, it's common to have a space in the path.
073263
+  */
073263
+     char_u *
073263
+ get_isolated_shell_name()
073263
+ {
073263
+     char_u *p;
073263
+ 
073263
+ #ifdef WIN3264
073263
+     p = gettail(p_sh);
073263
+     p = vim_strnsave(p, (int)(skiptowhite(p) - p));
073263
+ #else
073263
+     p = skiptowhite(p_sh);
073263
+     if (*p == NUL)
073263
+     {
073263
+ 	/* No white space, use the tail. */
073263
+ 	p = vim_strsave(gettail(p_sh));
073263
+     }
073263
+     else
073263
+     {
073263
+ 	char_u  *p1, *p2;
073263
+ 
073263
+ 	/* Find the last path separator before the space. */
073263
+ 	p1 = p_sh;
073263
+ 	for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
073263
+ 	    if (vim_ispathsep(*p2))
073263
+ 		p1 = p2 + 1;
073263
+ 	p = vim_strnsave(p1, (int)(p - p1));
073263
+     }
073263
+ #endif
073263
+     return p;
073263
+ }
073263
*** ../vim-7.4.275/src/option.c	2014-03-23 15:12:29.931264336 +0100
073263
--- src/option.c	2014-05-07 15:05:14.117105653 +0200
073263
***************
073263
*** 3804,3840 ****
073263
      else
073263
  	do_sp = !(options[idx_sp].flags & P_WAS_SET);
073263
  #endif
073263
! 
073263
!     /*
073263
!      * Isolate the name of the shell:
073263
!      * - Skip beyond any path.  E.g., "/usr/bin/csh -f" -> "csh -f".
073263
!      * - Remove any argument.  E.g., "csh -f" -> "csh".
073263
!      * But don't allow a space in the path, so that this works:
073263
!      *   "/usr/bin/csh --rcfile ~/.cshrc"
073263
!      * But don't do that for Windows, it's common to have a space in the path.
073263
!      */
073263
! #ifdef WIN3264
073263
!     p = gettail(p_sh);
073263
!     p = vim_strnsave(p, (int)(skiptowhite(p) - p));
073263
! #else
073263
!     p = skiptowhite(p_sh);
073263
!     if (*p == NUL)
073263
!     {
073263
! 	/* No white space, use the tail. */
073263
! 	p = vim_strsave(gettail(p_sh));
073263
!     }
073263
!     else
073263
!     {
073263
! 	char_u  *p1, *p2;
073263
! 
073263
! 	/* Find the last path separator before the space. */
073263
! 	p1 = p_sh;
073263
! 	for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
073263
! 	    if (vim_ispathsep(*p2))
073263
! 		p1 = p2 + 1;
073263
! 	p = vim_strnsave(p1, (int)(p - p1));
073263
!     }
073263
! #endif
073263
      if (p != NULL)
073263
      {
073263
  	/*
073263
--- 3804,3810 ----
073263
      else
073263
  	do_sp = !(options[idx_sp].flags & P_WAS_SET);
073263
  #endif
073263
!     p = get_isolated_shell_name();
073263
      if (p != NULL)
073263
      {
073263
  	/*
073263
***************
073263
*** 3875,3880 ****
073263
--- 3845,3851 ----
073263
  		    || fnamecmp(p, "zsh") == 0
073263
  		    || fnamecmp(p, "zsh-beta") == 0
073263
  		    || fnamecmp(p, "bash") == 0
073263
+ 		    || fnamecmp(p, "fish") == 0
073263
  #  ifdef WIN3264
073263
  		    || fnamecmp(p, "cmd") == 0
073263
  		    || fnamecmp(p, "sh.exe") == 0
073263
***************
073263
*** 8858,8865 ****
073263
   * opt_type). Uses
073263
   *
073263
   * Returned flags:
073263
!  *       0 hidden or unknown option, also option that does not have requested 
073263
!  *         type (see SREQ_* in vim.h)
073263
   *  see SOPT_* in vim.h for other flags
073263
   *
073263
   * Possible opt_type values: see SREQ_* in vim.h
073263
--- 8829,8836 ----
073263
   * opt_type). Uses
073263
   *
073263
   * Returned flags:
073263
!  *       0 hidden or unknown option, also option that does not have requested
073263
!  *	   type (see SREQ_* in vim.h)
073263
   *  see SOPT_* in vim.h for other flags
073263
   *
073263
   * Possible opt_type values: see SREQ_* in vim.h
073263
*** ../vim-7.4.275/src/proto/misc1.pro	2014-04-05 19:44:36.903160723 +0200
073263
--- src/proto/misc1.pro	2014-05-07 14:57:04.605101368 +0200
073263
***************
073263
*** 103,106 ****
073263
--- 103,107 ----
073263
  char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len));
073263
  void FreeWild __ARGS((int count, char_u **files));
073263
  int goto_im __ARGS((void));
073263
+ char_u *get_isolated_shell_name __ARGS((void));
073263
  /* vim: set ft=c : */
073263
*** ../vim-7.4.275/src/version.c	2014-05-07 14:38:41.129091709 +0200
073263
--- src/version.c	2014-05-07 14:58:59.769102376 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     276,
073263
  /**/
073263
073263
-- 
073263
Support your right to bare arms!  Wear short sleeves!
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///