Skip to content

Commit 426f375

Browse files
committed
patch 8.0.0060
Problem: When using an Ex command for 'keywordprg' it is escaped as with a shell command. (Romain Lafourcade) Solution: Escape for an Ex command. (closes #1175)
1 parent de5e2c2 commit 426f375

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

src/normal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5713,9 +5713,13 @@ nv_ident(cmdarg_T *cap)
57135713
*/
57145714
if (cmdchar == 'K' && !kp_help)
57155715
{
5716-
/* Escape the argument properly for a shell command */
57175716
ptr = vim_strnsave(ptr, n);
5718-
p = vim_strsave_shellescape(ptr, TRUE, TRUE);
5717+
if (kp_ex)
5718+
/* Escape the argument properly for an Ex command */
5719+
p = vim_strsave_fnameescape(ptr, FALSE);
5720+
else
5721+
/* Escape the argument properly for a shell command */
5722+
p = vim_strsave_shellescape(ptr, TRUE, TRUE);
57195723
vim_free(ptr);
57205724
if (p == NULL)
57215725
{

src/testdir/test_normal.vim

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ endfunc
12221222
func! Test_normal23_K()
12231223
" Test for K command
12241224
new
1225-
call append(0, ['version8.txt', 'man'])
1225+
call append(0, ['version8.txt', 'man', 'aa%bb', 'cc|dd'])
12261226
let k = &keywordprg
12271227
set keywordprg=:help
12281228
1
@@ -1237,6 +1237,24 @@ func! Test_normal23_K()
12371237
call assert_match('\*version8\.0\*', getline('.'))
12381238
helpclose
12391239

1240+
set keywordprg=:new
1241+
set iskeyword+=%
1242+
set iskeyword+=\|
1243+
2
1244+
norm! K
1245+
call assert_equal('man', fnamemodify(bufname('%'), ':t'))
1246+
bwipe!
1247+
3
1248+
norm! K
1249+
call assert_equal('aa%bb', fnamemodify(bufname('%'), ':t'))
1250+
bwipe!
1251+
4
1252+
norm! K
1253+
call assert_equal('cc|dd', fnamemodify(bufname('%'), ':t'))
1254+
bwipe!
1255+
set iskeyword-=%
1256+
set iskeyword-=\|
1257+
12401258
" Only expect "man" to work on Unix
12411259
if !has("unix")
12421260
let &keywordprg = k

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
60,
767769
/**/
768770
59,
769771
/**/

0 commit comments

Comments
 (0)