Patch 9.0.0783
Problem:    ":!" doesn't do anything but does update the previous command.
Solution:   Do not have ":!" change the previous command. (Martin Tournoij,
            closes #11372)
Files:      .gitignore, runtime/doc/various.txt, src/ex_cmds.c,
            src/testdir/test_shell.vim


*** ../vim-9.0.0782/.gitignore  2022-10-16 19:45:24.558960645 +0100
--- .gitignore  2022-10-17 17:48:31.361741928 +0100
***************
*** 85,90 ****
--- 85,91 ----
  src/testdir/viminfo
  src/testdir/opt_test.vim
  src/testdir/failed
+ src/testdir/starttime
  runtime/indent/testdir/*.out
  runtime/indent/testdir/*.fail
  src/memfile_test
*** ../vim-9.0.0782/runtime/doc/various.txt     2022-10-13 22:12:07.160673838 
+0100
--- runtime/doc/various.txt     2022-10-17 17:53:13.709188168 +0100
***************
*** 247,253 ****
  
                                                        *:!cmd* *:!*
  :!{cmd}                       Execute {cmd} with the shell.  See also the 
'shell'
!                       and 'shelltype' option.
                                                        *E34*
                        Any '!' in {cmd} is replaced with the previous
                        external command (see also 'cpoptions').  But not when
--- 249,256 ----
  
                                                        *:!cmd* *:!*
  :!{cmd}                       Execute {cmd} with the shell.  See also the 
'shell'
!                       and 'shelltype' option. `:!` without a {cmd} is a no-op,
!                       it does nothing.
                                                        *E34*
                        Any '!' in {cmd} is replaced with the previous
                        external command (see also 'cpoptions').  But not when
*** ../vim-9.0.0782/src/ex_cmds.c       2022-10-14 20:09:00.895207512 +0100
--- src/ex_cmds.c       2022-10-17 17:59:35.100744759 +0100
***************
*** 957,962 ****
--- 957,967 ----
        }
      } while (trailarg != NULL);
  
+     // Don't do anything if there is no command as there isn't really anything
+     // useful in running "sh -c ''".  Avoids changing "prevcmd".
+     if (STRLEN(newcmd) == 0)
+       return;
+ 
      vim_free(prevcmd);
      prevcmd = newcmd;
  
*** ../vim-9.0.0782/src/testdir/test_shell.vim  2022-10-10 22:39:38.203545897 
+0100
--- src/testdir/test_shell.vim  2022-10-17 17:48:31.361741928 +0100
***************
*** 251,254 ****
--- 251,285 ----
    call delete('Xtestout')
  endfunc
  
+ func Test_shell_repeat()
+   CheckUnix
+ 
+   let save_shell = &shell
+ 
+   call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell', 'D')
+   call setfperm('Xtestshell', "r-x------")
+   set shell=./Xtestshell
+   defer delete('Xlog')
+ 
+   call feedkeys(":!echo coconut\<CR>", 'xt')   " Run command
+   call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
+ 
+   call feedkeys(":!!\<CR>", 'xt')              " Re-run previous
+   call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
+ 
+   call writefile(['empty'], 'Xlog')
+   call feedkeys(":!\<CR>", 'xt')               " :! is a no-op
+   call assert_equal(['empty'], readfile('Xlog'))
+ 
+   call feedkeys(":!!\<CR>", 'xt')              " :! doesn't clear previous 
command
+   call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
+ 
+   call feedkeys(":!echo banana\<CR>", 'xt')    " Make sure setting previous 
command keeps working after a :! no-op
+   call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog'))
+   call feedkeys(":!!\<CR>", 'xt')
+   call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog'))
+ 
+   let &shell = save_shell
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0782/src/version.c       2022-10-17 15:28:44.019713168 +0100
--- src/version.c       2022-10-17 17:50:58.301421146 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     783,
  /**/

-- 
Violators can be fined, arrested or jailed for making ugly faces at a dog.
                [real standing law in Oklahoma, United States of America]

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221017170104.0694E1C0363%40moolenaar.net.

Raspunde prin e-mail lui