Skip to content

Instantly share code, notes, and snippets.

@chrisbra
Created April 20, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbra/2ab6f18365c6e7d4f291c6a0a49b82f2 to your computer and use it in GitHub Desktop.
Save chrisbra/2ab6f18365c6e7d4f291c6a0a49b82f2 to your computer and use it in GitHub Desktop.
Vim issue #1590
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 83bc8f379..884f4501c 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -7092,9 +7092,9 @@ shellescape({string} [, {special}]) *shellescape()*
{special}) when 'shell' contains "csh" in the tail. That is
because for csh and tcsh "!" is used for history replacement
even when inside single quotes.
- The <NL> character is also escaped. With a |non-zero-arg|
- {special} and 'shell' containing "csh" in the tail it's
- escaped a second time.
+ The <NL> character is also escaped when {special} is set.
+ With a |non-zero-arg| {special} and 'shell' containing "csh" in
+ the tail it's escaped a second time.
Example of use with a |:!| command: >
:exe '!dir ' . shellescape(expand('<cfile>'), 1)
< This results in a directory listing for the file under the
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 45c43f685..e1986e6c4 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -10473,8 +10473,10 @@ f_sha256(typval_T *argvars, typval_T *rettv)
static void
f_shellescape(typval_T *argvars, typval_T *rettv)
{
+ int do_special = non_zero_arg(&argvars[1]);
+
rettv->vval.v_string = vim_strsave_shellescape(
- get_tv_string(&argvars[0]), non_zero_arg(&argvars[1]), TRUE);
+ get_tv_string(&argvars[0]), do_special, do_special);
rettv->v_type = VAR_STRING;
}
@brammool
Copy link

The current behavior is the other way around for when 'shell' is "csh".
Thus the code should check for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment