From c0f10d3fe018990b68cfa47bd84693449100f449 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Apr 2023 14:09:29 +0800 Subject: vim-patch:9.0.0783: ":!" doesn't do anything but does update the previous command Problem: ":!" doesn't do anything but does update the previous command. Solution: Do not have ":!" change the previous command. (Martin Tournoij, closes vim/vim#11372) https://github.com/vim/vim/commit/8107a2a8af80a53a61734b600539c5beb4782991 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_shell.vim | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_shell.vim b/test/old/testdir/test_shell.vim index 3d0056bfc1..b65752dbf2 100644 --- a/test/old/testdir/test_shell.vim +++ b/test/old/testdir/test_shell.vim @@ -206,4 +206,35 @@ func Test_set_shell() 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\", 'xt') " Run command + call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) + + call feedkeys(":!!\", 'xt') " Re-run previous + call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) + + call writefile(['empty'], 'Xlog') + call feedkeys(":!\", 'xt') " :! is a no-op + call assert_equal(['empty'], readfile('Xlog')) + + call feedkeys(":!!\", 'xt') " :! doesn't clear previous command + call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) + + call feedkeys(":!echo banana\", 'xt') " Make sure setting previous command keeps working after a :! no-op + call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog')) + call feedkeys(":!!\", 'xt') + call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog')) + + let &shell = save_shell +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 187ba3efce4acc197ce6cc9559a905eec97bacbe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Apr 2023 14:23:09 +0800 Subject: vim-patch:9.0.0815 https://github.com/vim/vim/commit/9c50eeb40117413bf59a9da904c8d0921ed0a6e6 Co-authored-by: Martin Tournoij --- test/old/testdir/test_shell.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/old/testdir/test_shell.vim b/test/old/testdir/test_shell.vim index b65752dbf2..828fd1fa40 100644 --- a/test/old/testdir/test_shell.vim +++ b/test/old/testdir/test_shell.vim @@ -223,8 +223,8 @@ func Test_shell_repeat() call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) call writefile(['empty'], 'Xlog') - call feedkeys(":!\", 'xt') " :! is a no-op - call assert_equal(['empty'], readfile('Xlog')) + call feedkeys(":!\", 'xt') " :! + call assert_equal(['Cmd: [-c ]'], readfile('Xlog')) call feedkeys(":!!\", 'xt') " :! doesn't clear previous command call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog')) -- cgit From 9180c18c462a4945657899b732189da6f2ea2eaf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Apr 2023 14:31:40 +0800 Subject: vim-patch:9.0.0864: crash when using "!!" without a previous shell command Problem: Crash when using "!!" without a previous shell command. Solution: Check "prevcmd" is not NULL. (closes vim/vim#11487) https://github.com/vim/vim/commit/6600447c7b0a1be3a64d07a318bacdfaae0cac4b Co-authored-by: Bram Moolenaar --- test/old/testdir/test_shell.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_shell.vim b/test/old/testdir/test_shell.vim index 828fd1fa40..7172d5ba33 100644 --- a/test/old/testdir/test_shell.vim +++ b/test/old/testdir/test_shell.vim @@ -237,4 +237,17 @@ func Test_shell_repeat() let &shell = save_shell endfunc +func Test_shell_no_prevcmd() + " this doesn't do anything, just check it doesn't crash + let after =<< trim END + exe "normal !!\" + call writefile([v:errmsg, 'done'], 'Xtestdone') + qall! + END + if RunVim([], after, '--clean') + call assert_equal(['E34: No previous command', 'done'], readfile('Xtestdone')) + endif + call delete('Xtestdone') +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit