diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-06-05 18:46:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-06-05 18:46:26 +0200 |
commit | 206155280def51160a9d81d983aed639015ffb44 (patch) | |
tree | 1143d17e10d8b407fdabe0ced2a63b4fee28373b /src/testdir | |
parent | 6c95fbc9ae64f3a7619070e830f0c35aa4f0ada9 (diff) |
patch 8.0.0625: shellescape() always escapes a newlinev8.0.0625
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)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_functions.vim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index e569ef1dca..f0f656ac85 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -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 |