changeset 30961:22264b648b5d

patch 9.0.0815 Commit: https://github.com/vim/vim/commit/9c50eeb40117413bf59a9da904c8d0921ed0a6e6 Author: Martin Tournoij <martin@arp242.net> Date: Sat Oct 22 09:02:56 2022 +0100 patch 9.0.0815
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Oct 2022 10:15:05 +0200
parents 6b03468f9cf7
children 3a01529f17f5
files src/ex_cmds.c src/testdir/test_shell.vim src/version.c
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -929,6 +929,8 @@ do_bang(
 	    STRCAT(t, newcmd);
 	if (ins_prevcmd)
 	    STRCAT(t, prevcmd);
+	else
+	    vim_free(t);
 	p = t + STRLEN(t);
 	STRCAT(t, trailarg);
 	vim_free(newcmd);
@@ -957,17 +959,13 @@ do_bang(
 	}
     } 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)
+    // Don't clear "prevcmd" if there is no command to run.
+    if (STRLEN(newcmd) > 0)
     {
-	vim_free(newcmd);
-	return;
+	vim_free(prevcmd);
+	prevcmd = newcmd;
     }
 
-    vim_free(prevcmd);
-    prevcmd = newcmd;
-
     if (bangredo)	    // put cmd in redo buffer for ! command
     {
 	// If % or # appears in the command, it must have been escaped.
--- a/src/testdir/test_shell.vim
+++ b/src/testdir/test_shell.vim
@@ -268,8 +268,8 @@ func Test_shell_repeat()
   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')               " :!
+  call assert_equal(['Cmd: [-c ]'], readfile('Xlog'))
 
   call feedkeys(":!!\<CR>", 'xt')              " :! doesn't clear previous command
   call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    815,
+/**/
     814,
 /**/
     813,