mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.0.0625: shellescape() always escapes a newline
Problem: shellescape() always escapes a newline, which does not work with some shells. (Harm te Hennepe) Solution: Only escape a newline when the "special" argument is non-zero. (Christian Brabandt, closes #1590)
This commit is contained in:
@@ -784,3 +784,28 @@ func Test_redo_in_nested_functions()
|
||||
delfunc Operator
|
||||
delfunc Apply
|
||||
endfunc
|
||||
|
||||
func Test_shellescape()
|
||||
let save_shell = &shell
|
||||
set shell=bash
|
||||
call assert_equal("'text'", shellescape('text'))
|
||||
call assert_equal("'te\"xt'", shellescape('te"xt'))
|
||||
call assert_equal("'te'\\''xt'", shellescape("te'xt"))
|
||||
|
||||
call assert_equal("'te%xt'", shellescape("te%xt"))
|
||||
call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
|
||||
call assert_equal("'te#xt'", shellescape("te#xt"))
|
||||
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
|
||||
call assert_equal("'te!xt'", shellescape("te!xt"))
|
||||
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
|
||||
|
||||
call assert_equal("'te\nxt'", shellescape("te\nxt"))
|
||||
call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
|
||||
set shell=tcsh
|
||||
call assert_equal("'te\\!xt'", shellescape("te!xt"))
|
||||
call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1))
|
||||
call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
|
||||
call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
|
||||
|
||||
let &shell = save_shell
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user