Mercurial > vim
diff src/testdir/test_shell.vim @ 30898:2ee5b79038f0 v9.0.0783
patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Commit: https://github.com/vim/vim/commit/8107a2a8af80a53a61734b600539c5beb4782991
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 17 18:00:23 2022 +0100
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 #11372)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Oct 2022 19:15:04 +0200 |
parents | ae10b91ac6b3 |
children | 22264b648b5d |
line wrap: on
line diff
--- a/src/testdir/test_shell.vim +++ b/src/testdir/test_shell.vim @@ -251,4 +251,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\<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