-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cmd.exe shellescape. Add plug#shellescape
- Loading branch information
Showing
3 changed files
with
46 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Execute (plug#shellescape() works without optional arguments): | ||
if has('unix') | ||
AssertEqual plug#shellescape(""), "''" | ||
AssertEqual plug#shellescape("foo'"), "'foo'\\'''" | ||
endif | ||
|
||
Execute (plug#shellescape() ignores invalid optional argument): | ||
if has('unix') | ||
AssertEqual plug#shellescape("", ''), "''" | ||
AssertEqual plug#shellescape("foo'", []), "'foo'\\'''" | ||
endif | ||
|
||
Execute (plug#shellescape() depends on the shell): | ||
AssertEqual plug#shellescape("foo'", {'shell': 'sh'}), "'foo'\\'''" | ||
AssertEqual plug#shellescape("foo'", {'shell': 'cmd.exe'}), '^"foo''^"' | ||
AssertEqual plug#shellescape("foo'", {'shell': 'powershell.exe'}), "'foo'''" | ||
|
||
Execute (plug#shellescape() supports non-trivial cmd.exe escaping): | ||
" batchfile | ||
AssertEqual plug#shellescape("^%PATH^%", {'shell': 'cmd.exe'}), | ||
\ '^"^^%%PATH^^%%^"' | ||
AssertEqual plug#shellescape("^%PATH^%", {'shell': 'cmd.exe', 'script': 1}), | ||
\ '^"^^%%PATH^^%%^"' | ||
" command prompt | ||
AssertEqual plug#shellescape("^%PATH^%", {'shell': 'cmd.exe', 'script': 0}), | ||
\ '^"^^^%PATH^^^%^"' | ||
|
||
Execute (plug#shellescape() supports non-trivial powershell.exe escaping): | ||
AssertEqual plug#shellescape('"Foo\''\Bar"', {'shell': 'powershell.exe'}), | ||
\ '''\"Foo\\''''\\Bar\"''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters