Patch 9.0.0845
Problem: Shell command with just space gives strange error.
Solution: Skip white space at start of the argument. (Christian Brabandt,
Shane-XB-Qian, closes #11515, closes #11495)
Files: src/ex_cmds.c, src/testdir/test_cmdline.vim
*** ../vim-9.0.0844/src/ex_cmds.c 2022-10-29 21:18:53.875116353 +0100
--- src/ex_cmds.c 2022-11-08 21:13:18.642657415 +0000
***************
*** 899,909 ****
}
/*
! * Try to find an embedded bang, like in :!<cmd> ! [args]
! * (:!! is indicated by the 'forceit' variable)
*/
ins_prevcmd = forceit;
! trailarg = arg;
do
{
len = (int)STRLEN(trailarg) + 1;
--- 899,911 ----
}
/*
! * Try to find an embedded bang, like in ":!<cmd> ! [args]"
! * ":!!" is indicated by the 'forceit' variable.
*/
ins_prevcmd = forceit;
!
! // Skip leading white space to avoid a strange error with some shells.
! trailarg = skipwhite(arg);
do
{
len = (int)STRLEN(trailarg) + 1;
*** ../vim-9.0.0844/src/testdir/test_cmdline.vim 2022-10-06
11:38:48.154906022 +0100
--- src/testdir/test_cmdline.vim 2022-11-08 21:38:37.161496604 +0000
***************
*** 1653,1658 ****
--- 1653,1705 ----
%bwipe!
endfunc
+ func Test_cmd_bang_args()
+ new
+ :.!
+ call assert_equal(0, v:shell_error)
+
+ " Note that below there is one space char after the '!'. This caused a
+ " shell error in the past, see https://github.com/vim/vim/issues/11495.
+ :.!
+ call assert_equal(0, v:shell_error)
+ bwipe!
+
+ CheckUnix
+ :.!pwd
+ call assert_equal(0, v:shell_error)
+ :.! pwd
+ call assert_equal(0, v:shell_error)
+
+ " Note there is one space after 'pwd'.
+ :.! pwd
+ call assert_equal(0, v:shell_error)
+
+ " Note there are two spaces after 'pwd'.
+ :.! pwd
+ call assert_equal(0, v:shell_error)
+ :.!ls ~
+ call assert_equal(0, v:shell_error)
+
+ " Note there is one space char after '~'.
+ :.!ls ~
+ call assert_equal(0, v:shell_error)
+
+ " Note there are two spaces after '~'.
+ :.!ls ~
+ call assert_equal(0, v:shell_error)
+
+ :.!echo "foo"
+ call assert_equal(getline('.'), "foo")
+ :.!echo "foo "
+ call assert_equal(getline('.'), "foo ")
+ :.!echo " foo "
+ call assert_equal(getline('.'), " foo ")
+ :.!echo " foo "
+ call assert_equal(getline('.'), " foo ")
+
+ %bwipe!
+ endfunc
+
" Test for using ~ for home directory in cmdline completion matches
func Test_cmdline_expand_home()
call mkdir('Xexpdir', 'R')
*** ../vim-9.0.0844/src/version.c 2022-11-07 12:16:46.397761740 +0000
--- src/version.c 2022-11-08 21:11:00.942745891 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 845,
/**/
--
If you put seven of the most talented OSS developers in a room
and ask them to fix a bug in a spreadsheet program, in one week
you'd have 2 new mail readers and a text-based web browser.
/// 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/20221108214038.026B21C076D%40moolenaar.net.